Domanda

In this article, the author mentioned the following: Also we were reading post image and updating the post image as it is. This was also creating a problem. Please create a new object of Entity and then set only those fields which you want to update. Then update the record.

How to create a new object of PostImage Entity?

È stato utile?

Soluzione

PostImage, PreImage and Target all translate to Entity.

e.g.

Entity myEntity = new Entity("new_entityname");
myEntity["attriubteName"] = "String Data";
Guid returnId = service.Create(myEntity);

The author of the article above suggested that in order to avoid his issues you should not edit and update the context.PostEntityImage["PostImageKey"] directly but map the attributes you want to update to a new Entity like so

//context post image Entity
Entity postMessageImage = (Entity)context.PostEntityImages["PostImage"];
//new Entity 
Entity myEntity = new Entity("new_entityname");
//map and update
myEntity["attriubteName"] = postMessageImage["attributeName"];
myEntity["attriubteId"] = postMessageImage["attributeId"];
service.Update(myEntity);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top