Entity Framework 删除与 State.Deleted
Entity Framework Remove vs State.Deleted
简单明了,
有区别吗
DbSet().Remove(x)
到
context.Entry(x).State = State.Deleted?
谢谢
我不知道,删除的 MSDN 文章说
Marks the given entity as Deleted such that it will be deleted from the database when SaveChanges is called. Note that the entity must exist in the context in some other state before this method is called.
。删除可能只是删除项目的首选方式。
编辑:
另外,关于 EntityState 的 MSDN 文章说这个被删除了。
The entity is being tracked by the context and exists in the database, but has been marked for deletion from the database the next time SaveChanges is called.
这进一步证实了它们实际上是同一回事。
简单明了,
有区别吗DbSet().Remove(x)
到
context.Entry(x).State = State.Deleted?
谢谢
我不知道,删除的 MSDN 文章说
Marks the given entity as Deleted such that it will be deleted from the database when SaveChanges is called. Note that the entity must exist in the context in some other state before this method is called.
。删除可能只是删除项目的首选方式。
编辑:
另外,关于 EntityState 的 MSDN 文章说这个被删除了。
The entity is being tracked by the context and exists in the database, but has been marked for deletion from the database the next time SaveChanges is called.
这进一步证实了它们实际上是同一回事。