Print Page | Close Window

SaveChangesAsync and associated entities

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2802
Printed Date: 04-May-2025 at 3:23am


Topic: SaveChangesAsync and associated entities
Posted By: MVenhola
Subject: SaveChangesAsync and associated entities
Date Posted: 28-Jun-2011 at 8:11am
When passing an IEnumerable to SaveChangesAsync, are the associated entities saved as well?
 
ie:
 
A Project entity has an associated list of Contacts.
 
em.SaveChangesAsync(Projects, callback);
 
Are the Contacts saved as well?



Replies:
Posted By: sbelini
Date Posted: 28-Jun-2011 at 8:56am
Hi MVenhola,
 
When you are doing a 'partial' save, only the entities passed on to the save are actually saved:
 
If you want to also save the contacts, you will need to pass them to the SaveChanges call.
 
In the http://drc.ideablade.com/xwiki/bin/view/Documentation/save-dependency-graph - DevForce Resource Center you will find an article on saving a graph of entities.
 
Regards,
   Silvio.



Print Page | Close Window