.net - Submit changes of only one entity -


if select many rows 1 table 1 instance of datacontext. , changes in properties in rows, can submit changes database 1 of selected rows?

yes can.

first need isolate entities want undo changes. then, can use datacontext class override entities values database.

myentity e1, e2, e3 // changed entities ... // keep changes e3 list<myentity> undolist = new list<myentity>(); undolist.add(e1); undolist.add(e2); mydatacontext.refresh(refreshmode.overwritecurrentvalues, undolist);  mydatacontext.submitchanges(); 

edit:

you can track changed objects in datacontext this:

myentity changedentitytosubmit; // first need know entity need submit. list<object> allchangedentities = new list<object>(mydatacontext.getchangeset().updates); allchangedentities.remove(changedentitytosubmit);  mydatacontext.refresh(refreshmode.overwritecurrentvalues, allchangedentities);  mydatacontext.submitchanges(); 

this code considering updates. might need consider changes in inserts , deletes. you.


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -