this was crazy the solution was found in the following thread
http://stackoverflow.com/questions/2113498/sqlexception-from-entity-framework-new-transaction-is-not-allowed-because-there/3902790#3902790
Reason: we cannot do savechanges while still the reader is open.
//This will fail because we are doing savechanges while the reader is open
xs= Dataservice.GetX().Where(x=>!x.Ideleted)
foreach(x in xs)
{
//do something
Savechanges()
}
//this will succed becasuse we did a tolist(which closed the reader) and then did savechanges
xs= Dataservice.GetX().Where(x=>!x.Ideleted).ToList();
foreach(x in xs)
{
//do something
Savechanges()
}
No comments:
Post a Comment