EF 执行顺序--先删除在更新和添加

public void AcceptAllChanges()
{
if (this.ObjectStateManager.SomeEntryWithConceptualNullExists())
{
throw new InvalidOperationException(System.Data.Entity.Strings.ObjectContext_CommitWithConceptualNull);
}
foreach (ObjectStateEntry entry in this.ObjectStateManager.GetObjectStateEntries(EntityState.Deleted))
{
entry.AcceptChanges();
}
foreach (ObjectStateEntry entry2 in this.ObjectStateManager.GetObjectStateEntries(EntityState.Modified | EntityState.Added))
{
entry2.AcceptChanges();
}
}

posted on 2015-12-09 14:47  codecraft  阅读(882)  评论(0)    收藏  举报

导航