save single entity AND child entities (EntityGraph saving?)

Dec 30, 2010 at 7:04 PM
Edited Dec 30, 2010 at 7:06 PM

this is a continuation from the previous thread which dealt with saving a single entity with no child entities:

So the question is, will code described in that post suffice for saving an entity with for instance, a child property of List<AnotherEntityType>, or will a solution which utilizes the EntityGraph be required?

Dec 30, 2010 at 7:42 PM

No, that code doesn't account for children and I believe that Merijn's EntityGraph code would be the best way to implement it. Do you have any interest in contributing code to Contrib Joe? If you are interested in getting this working I would welcome the input.

Dec 30, 2010 at 9:43 PM

That's what I figured. 

As for contrib'n to Contrib, sure! 

That being said -- as time permits. Due to our project timeline being so aggressive, I might not be able to spend enough time using the entity graph and abstracting it all out of our implementation if I end up using it. Perhaps phase 2.5: re-factor & nicety-add :)

We're not quite to the point where we will be implementing this functionality, but it will be soon.
I'll keep ya posted on my progress. In the meantime, feel free to add me as a contributer :)

Jul 6, 2011 at 2:54 PM

I'm trying to do a partial save of an entity graph as mentioned in the thread linked above.  How would I go about doing that?

MyDomainContext tempContext = new MyDomainContext();

EntityGraphShape shape = new EntityGraphShape()
                .Edge<Order, OrderDetail>(order => order.OrderDetails);                       
EntityGraph graph = Entity.EntityGraph(shape);

// what do I need to do here to move my order and the
// orderdetails added to it or removed from it to the
// tempContext

Jul 27, 2011 at 4:46 AM

Here is a blog post that adds some extensions methods to do a partial save using an Entity Graph:

Oct 15, 2011 at 12:21 PM

Hi c0sm0,

I visited the aforementioned link but it's not pretty clear how the entity relationship is. If you were able to crack, could you please share.

Nov 28, 2011 at 4:31 PM

With my recent additions to EntityGraph, doing a partial save has become pretty straight-forward. Checkout this link for a step-by-step guide. Don't forget to also read the disclaimer though.

Nov 28, 2011 at 9:49 PM
Thanks Mdej, this will be great to use in our upcoming project. :-)
Tel +61(0) 2 61312158 Ext 142158 Mob +61(0) 415203666

From: MdeJ [email removed]
Sent: Tuesday, 29 November 2011 3:32 AM
To: Brown, Justin
Subject: Re: save single entity AND child entities (EntityGraph saving?) [RiaServicesContrib:240034]

From: MdeJ

With my recent additions to EntityGraph, doing a partial save has become pretty straight-forward. Checkout this link for a step-by-step guide. Don't forget to also read the disclaimer though.


This email message and any attached files may contain information
that is confidential and subject of legal privilege intended only for
use by the individual or entity to whom they are addressed. If you
are not the intended recipient or the person responsible for
delivering the message to the intended recipient be advised that you
have received this message in error and that any use, copying,
circulation, forwarding, printing or publication of this message or
attached files is strictly forbidden, as is the disclosure of the
information contained therein. If you have received this message in
error, please notify the sender immediately and delete it from your

AFP Web site:
Nov 28, 2011 at 9:55 PM

agreed. this is an awesome update!

one thing, however .. 

I thought I overlooked something, but I can't find where the cloned entities had their newly updated states copied back onto the originals in the non-partial-save context?

I suppose this assumes no changes will be made server-side, but sometimes (often?) this isn't the case.
(Off the top of my head I think of a common situation: any database-generated value: IDs, timestamps, etc)

Nov 29, 2011 at 8:55 PM

@joebrockhaus: You're completely right! For some reason I overlooked this scenario. Fortunately with EntityGraph this is easy to fix. I've updated the documentation here, so it should now work correctly. Thanks for informing.

Nov 29, 2011 at 8:59 PM

awesome. the Synchronize method makes that cake :D