You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Backstory: I have implemented repositories that store the data. In each of the DbContext models i have attached an auditlog handler to catch changes and log them using another repository.
public override int SaveChanges(bool acceptAllChangesOnSuccess)
{
AuditLog[] logs = null;
if (_auditLogTracker != null)
logs = _auditLogTracker.TrackChanges(this);
var result = base.SaveChanges(acceptAllChangesOnSuccess);
if (_auditLogTracker != null && logs != null)
_auditLogTracker.Save(logs);
return result;
}
Error: Collection was modified; enumeration operation may not execute.
The error is due to a new context being added while looping through contexts and performing commit.
Could the DbContextCollection perform other than foreach loops to go through the list to allow for new contexts being added during savechanges?
for(var i = 0; i contexts.length; i++)
{
//would probably allow for dynamicly injected contexts
}
The text was updated successfully, but these errors were encountered:
Backstory: I have implemented repositories that store the data. In each of the DbContext models i have attached an auditlog handler to catch changes and log them using another repository.
Error: Collection was modified; enumeration operation may not execute.
The error is due to a new context being added while looping through contexts and performing commit.
Could the DbContextCollection perform other than foreach loops to go through the list to allow for new contexts being added during savechanges?
for(var i = 0; i contexts.length; i++)
{
//would probably allow for dynamicly injected contexts
}
The text was updated successfully, but these errors were encountered: