What is the ObjectContext equivalent? DbContext ApplyCurrentValues

c# entity-framework

Question

What does DbContext's version of ObjectContext.ApplyCurrentValues look like?

1
34
4/27/2011 4:46:32 PM

Accepted Answer

There is no analogous thing. You may get the ObjectContext either by...

((IObjectContextAdapter)myDbContext).ObjectContext.ApplyCurrentValues(...)

...or use a similar technique ofDbEntityEntry :

 myDbContext.Entry(originalEntity).CurrentValues.SetValues(changedEntity);

originalEntity depicts the thing as it was before the alteration (usually fetched from database before you update). It must be related to the situation.changedEntity indicates the object that has changed that has the same key.

This second strategy is most likely strongly connected to theObjectStateEntry.ApplyCurrentValues technique of EF 4.0.

48
4/27/2011 5:24:56 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow