DataContext life cicle

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
Posts: 16
Joined: Wed 28 Jun 2017 12:35

DataContext life cicle

Post by -marcelo- » Wed 09 Aug 2017 14:34

LinqConnect and Entity Developer newbie.
My question is related to the DataContext life cicle.
If I want to insert a new entity, I could do

Code: Select all

          SomeEntity instance = new SomeEntity(); 
// set the properties 
          using (DataContext context = new DataContext()) {
// the life cicle of the DataContext is very short
I was seeing the Attach method overloads, specifically Attach(changed, original).
Having that, I could use an instance of DataContext to read the "original" entity and dispose it immediately. After the user is done with editing on a copy (changed) a could instance a new DataContext, Attach both instances and call SubmitChanges()?

Tested: it´s the way to go. Attach( changed, original ); then SubmitChanges();


Devart Team
Posts: 7976
Joined: Thu 14 Aug 2008 12:44

Re: DataContext life cicle

Post by Shalex » Thu 10 Aug 2017 15:10

Thank you for confirming solution. As we understood, no investigation on our side is required.

Post Reply