c# - EF ObjectContext updating entity closed context -
i have problems updating entities objectcontext. context closed when update takes place need attach new context , save it.
context.attachto(navigation, item);
takes 10 seconds works. in generic repository:
using (var context = new model(this._connectionstring)) { (int = 0; < objects.count(); i++) { var item = objects[i]; context.attachto(navigation, item); context.objectstatemanager.changeobjectstate(item, system.data.entitystate.modified); } context.savechanges(); }
i insert 1 item on specific update.
i wonder if there else can make go faster. this:
var previous = context.createobjectset<entitymodel>() .where(s => s.id == updateditem.id).firstordefault<entitymodel>();
and save it. if know how gladly accept :)
thanks!
Comments
Post a Comment