c# - Use EF changetracker to manually get set of changes? -


if load entity, make changes, , go save it, ef generates update statement.

this must mean @ point (presumably change tracker) navigating loaded object hierarchy , generating list of (entity, property, value) changed. unrelated bit of infrastructure need diff object graphs in similar fashion. i'm thinking should able reuse same mechanism.

so that's question - can this? can query changes particular entity or entire object graph? how?

you use context's dbchangetracker returns ienumerable<dbentityentry>. loop on these comparing currentvalues originalvalues. original values values last query db.

foreach (dbentityentry entity in          changetracker.entries().where(e => e.state == entitystate.modified) {     foreach (var propname in entity.currentvalues.propertynames)     {         var current = entity.currentvalues[propname];         var original = entity.originalvalues[propname];     } } 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -