locked
EF RIA delete a single entity without submitting changes to entire context RRS feed

  • Question

  • OK, after quite a bit of study I can update a single entity without updating the entire context.  I accomplished this with help from the Contrib project (using entitygraphs) and a couple extension methods I found here http://4-getful.blogspot.com/2011/07/using-ria-services-contribs-entitygraph.html In essence doing the save in a temporary context and then updating the status of the original entity in the original context.  I learned quite a bit in the process.  Now I need to be able to delete an entity without committing updates that may exist in other entities.  I'm really not sure how to appproach this. 

    What I want to accomplish is the same feel as working with "document(s)" eg.  new / open existing - edit - save / save as  without effecting other "docs(entities)"  In my app this is important, as often changes will be "abandoned" or "rolled back" as the entities are used for design rather than data entry.  Users will typically have a half dozen designs active.  Not being able to handle CRUD individually is a killer.

    (The Entities contain several 1-many relationships)

    Anyone know of examples for this type of requirement? It must be fairly common 

    Friday, October 7, 2011 8:13 PM

Answers

  • What part of doing this for a deleted entity are you unclear on? If it is getting the entities to delete you can get that from the ChangeSet of the original Context. If it is how to clone them over, you clone them normally like you would for an update but then you need to loop through them and remove. I am not sure Merijn has EntityGraph setup to know how to clone deletes, the EntityTools section of Contrib does know how to clone deletes but not in a graph based way.

    Monday, October 10, 2011 10:28 AM

All replies

  • Hi,

    You can create a new instance of the domain context and then submit your single change by that instance.

    Monday, October 10, 2011 12:46 AM
  • What part of doing this for a deleted entity are you unclear on? If it is getting the entities to delete you can get that from the ChangeSet of the original Context. If it is how to clone them over, you clone them normally like you would for an update but then you need to loop through them and remove. I am not sure Merijn has EntityGraph setup to know how to clone deletes, the EntityTools section of Contrib does know how to clone deletes but not in a graph based way.

    Monday, October 10, 2011 10:28 AM