save single entity AND child entities (EntityGraph saving?)

Developer
Dec 30, 2010 at 6:04 PM
Edited Dec 30, 2010 at 6:06 PM

this is a continuation from the previous thread which dealt with saving a single entity with no child entities: 
http://riaservicescontrib.codeplex.com/Thread/View.aspx?ThreadId=236440&ANCHOR#Post542259

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?

Coordinator
Dec 30, 2010 at 6: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.

Developer
Dec 30, 2010 at 8: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 1: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
tempContext.SubmitChanges();

Jul 27, 2011 at 3:46 AM

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

http://4-getful.blogspot.com/2011/07/using-ria-services-contribs-entitygraph.html

Oct 15, 2011 at 11:21 AM

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.

Developer
Nov 28, 2011 at 3: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 8:49 PM
Thanks Mdej, this will be great to use in our upcoming project. :-)
JUSTIN BROWN
USER INTERFACE TECHNICAL LEAD - APPLICATIONS DEVELOPMENT
INFORMATION & COMMUNICATIONS TECHNOLOGY
AUSTRALIAN FEDERAL POLICE
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.




**********************************************************************
WARNING

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
inbox.

AFP Web site: http://www.afp.gov.au
**********************************************************************
Developer
Nov 28, 2011 at 8: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)

Developer
Nov 29, 2011 at 7: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.

Developer
Nov 29, 2011 at 7:59 PM

awesome. the Synchronize method makes that cake :D