c# - removing/detaching duplicate entity from local context -


i detaching every student entity local context. following code works fine , detach every entry of student entity local context.

_context.set<students>().local.tolist().foreach(x => {     _context.entry(x).state = entitystate.detached; }); 

what if need remove/detach duplicate entry of student local context? how can that?

i using ef 5.0

easier check when adding isn't duplicate.

but group, skip first , detach rest?

_context.set<students>()         .local         .tolist()         .groupby(x => x.name)         .selectmany(g=>g.skip(1))         .foreach(x => {      _context.entry(x).state = entitystate.detached; }); 

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -