Calling Store() on updates

14 views
Skip to first unread message

Nicolas Garfinkiel

unread,
Jun 8, 2012, 2:26:04 PM6/8/12
to rav...@googlegroups.com
Hey guys,

Just want to check... There is no need to call store to save changes to an entity loaded from the db and modified, because that entity is being tracked and whatever you do to it, the session knows about it and it will persist that change, right?

I dunno if I like it if it is the case, but I want to confirm it is a desired effect.

Cheers.

Bryan Johns

unread,
Jun 8, 2012, 3:31:09 PM6/8/12
to rav...@googlegroups.com
Just call session.SaveChanges();

--
Bryan Johns
K4GDW
http://www.greendragonweb.com

Do not meddle in the affairs of dragons, for you are crunchy and taste
good with ketchup.

Nicolas Garfinkiel

unread,
Jun 8, 2012, 3:52:16 PM6/8/12
to rav...@googlegroups.com
Yes, I know that. :-) I see I failed to add that I'm using an unit of work that at the end of the request will call for a SaveChanges if no errors occured.

Basically I wamt to confirm that you don't have to call Store() explicitly qhe you want to modify a loaded entity. SaveChanges will persist anything that it's tracking...

Cheers!


On Friday, June 8, 2012 4:31:09 PM UTC-3, Bryan Johns wrote:
Just call session.SaveChanges();

--
Bryan Johns
K4GDW
http://www.greendragonweb.com

Do not meddle in the affairs of dragons, for you are crunchy and taste
good with ketchup.


Matt Warren

unread,
Jun 8, 2012, 5:36:44 PM6/8/12
to rav...@googlegroups.com
Yeah, when you call SaveChanges() is will look at all the entities that have been loaded in the current session and save any of them that have been modified since they were originally loaded. This includes entites loaded directly or via the result of a query.

Nicolas Garfinkiel

unread,
Jun 8, 2012, 5:43:56 PM6/8/12
to rav...@googlegroups.com
Ok, thanks for the input, Matt!
Reply all
Reply to author
Forward
0 new messages