how to delete custom data which are related to schema definition? - microsoft-graph-api

I am planning to use Microsoft Graph API schema extension for user and groups. I am going to add custom data to user with schema extension property. How can I delete that schema extension custom data from user if it is no longer required.

You can only delete a schema extension if the current state is InDevelopment. From the documentation:
Only the app that created the schema extension (owner app) can delete the schema extension definition, and only when the extension is in the InDevelopment state. Deleting a schema extension definition does not affect accessing custom data that has been added to resource instances based on that definition.
Once it is out of development, you can only set the value to null. From the documentation:
You can also remove custom data added to a resource instance by setting the corresponding extension property to null.

Related

Remove or Add an attribute to CoreData at runtime programmatically

I have to create and remove attributes based on an api response in Objective C.
For example, Now my api response contains fields "facebook", "whatsapp" and "viber". But in future the reponse can add "youtube". Based on this response, I have to remove all the attributes and values of an entity "Social", and create Four attributes now and set values.
How to do that programmatically? Because the default *.xcdatamodeld file cant help me here, right?
Note: My project is in objective C.
The data model is mutable when the app starts-- you can completely build the model in code, and not use the model editor, for example. But as soon as you load a persistent store file, you must treat the model as fixed. Any changes after loading a persistent store will cause crashes. That means any changes would have to happen before calling either loadPersistentStores(completionHandler:) or addPersistentStore(with:completionHandler:).
Alexander's suggestion of optional attributes is a good one. If you need the model to be more dynamic, you would need to create a new related entity which would store the service name plus whatever information you need to save about the service. If you did this, your Social entity would have a to-many relationship to a new entity called something like Service. Service would have a string property called name that would have values like twitter, facebook, youtube, etc. It would also have whatever other attributes you need to save about the service.
You can create all 4 fields in advance and just make them optional and fill them depending on the server response. But you cannot add new attributes in runtime. Your *.xcdatamodeld file compiles into *.momd and it contains all the data to create tables in the DB since Core Data by default works with SQLite under the hood and it's a relational database management system.
To make attributes optional you should check that.
And then newly created objects contain nil as default values of object properties. So, in your case your "youtube" property of Social object will be just nil.

Proper way of using Marten for ASP.NET MVC/Core

I just discovered Marten today and currently trying to learn on how to use this properly.
For creating new records, it can be as straight forward as providing a blank form/view then during submission - just open a new session then perform the saving like this:
using (var session = _documentStore.LightweightSession())
{
session.Store(model);
session.SaveChanges();
}
But how about the updating existing records? After fetching the record and displaying it on the form, is it fine to just use the same code as I used above or is there another way? The only example I found for updating is loading the record from session by calling Load() method then editing the properties, after that is calling the SaveChanges() method of the session used.
Marten tracks documents using the document identity. The Id can be either a public field or property, and the name must be either id or Id or ID.
Quote from the doc:
Marten's .Net API makes no distinctions between inserts and updates.
The Postgresql functions generated by Marten to update the document
storage tables perform "upserts" for you. Anytime a document is
registered through IDocumentSession.Store(document), Marten runs the
"auto-assignment" policy for the id type of that document. See
Document Identity for more information on document id's.
This means that you don't necessarily need to load a document before updating it. If you know its identity value, you could simply change some property on the document and call IDocumentSession.Store(document) which will perform an update if a document with this id already exists in the datastore.

OData Model not loaded?

I am using an OData model in my SAP UI5 application. I do the following:
var oView = this.getView();
this._oModel = oView.getModel();
which I thought loaded the model and allowed me to access whatever I needed to inside the model. However whenever I try to get a property using getProperty(path) it returns undefined. I know the path is correct because I used it elsewhere in my application and it worked okay. The model I am using is named "metadata.xml" if that helps.
If you read the documentation provided by SAP talking about OData services (I assume v2), you might find your answer there. Since you are using getProperty(), "you can only access single entities and properties with these methods. To access entity sets, you can get the binding contexts of all read entities via a list binding." Therefore you may want to a read() of the entity set first and then use the results of this read to access whatever property you want.
Link to doc: https://sapui5.hana.ondemand.com/#docs/guide/6c47b2b39db9404582994070ec3d57a2.html

Can I prevent RestKit+CoreData from overriding local entity changes?

I've configured a RKObjectMappingProvider subclass with a series of object mappings that map a variety of service endpoints to my local Core Data entities & persistent store. Let's say I have a service endpoint /api/workorders and I use loadObjectsAtResourcePath:usingBlock: to fetch a list of X workorders and persist to Core Data. Next, the user modifies 2 of those entities using the app but doesn't push the changes back to the service.
If the user again calls /api/workorders to fetch the latest workorders, is there a way to not have RestKit automatically override the local modifications to the changed entities?
The short answer is no, you have to do it yourself and it gets nasty quickly.
You would need to override the setter of a custom managed object class.
This kind of thing.
You would need a property to know it has been updated. You will need to create it and set it when the entity gets updated. I would do this at the row level,
and then check the property and only update if the flag is not set.
Of course you then need to handle the case if the user wants to update the value again :)
Restkit is wonderful, but does not handle full syncing for you.

View Model Binding/AutoMapper

I am using Entity Framework 4 with the Service/Repository/EF4/POCO classes technique, and I have a question about View Model binding.
When you map a class to a view model and only take the fields the view needs, then map it back to a new instance of the class to persist to the database, how do you prevent the fields not used in the view from getting overwritten?
This is usually performed by loading entity from db first and merging incomming data to this entity (ObjectContext will track changes and update only changed properties). Another approach is manually set which properties where modified in state manager:
context.MyEntities.Attach(entity);
context.ObjectStateManager.GetObjectStateEntry(entity).SetModifiedProperty("Name");
Now when you save changes only Name property of the entity will be included in Update SQL command.
When using repostiory check high level example I shown here.

Resources