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

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -