在LINQ到SQL和SaveChanges的实体框架的SubmitChanges之间的技术区别是什么? [英] What is technical difference between SubmitChanges in Linq-to-SQL and SaveChanges in Entity Framework?
问题描述
在和实体LINQ到SQL 的SaveChanges
框架之间的的SubmitChanges
技术有什么区别?
What is technical difference between SubmitChanges
in Linq-to-SQL and SaveChanges
in Entity Framework?
我们知道的SubmitChanges
是的DataContext
类的一个概念,而的SaveChanges
是一个方法的ObjectContext
。
We know SubmitChanges
is a concept for DataContext
class while SaveChanges
is a method of ObjectContext
.
有没有另一种不同?
感谢
推荐答案
从MSDN:
的SaveChanges 在一个事务中运行。调用SaveChanges将回滚事务并抛出一个异常,如果有脏ObjectStateEntry对象不能被持续
SaveChanges operates within a transaction. SaveChanges will roll back that transaction and throw an exception if any of the dirty ObjectStateEntry objects cannot be persisted
的SubmitChanges 启动一个事务,将回滚如果在的SubmitChanges正在执行发生异常。然而,这并不回滚存储器或改变由在DataContext跟踪;这些变化将需要手动回滚。可以用在DataContext的新实例开始,如果变化存储器被丢弃。
SubmitChanges starts a transaction and will roll back if an exception occurs while SubmitChanges is executing. However, this does not roll back the changes in memory or tracked by the DataContext; those changes will need to be rolled back manually. You can start with a new instance of the DataContext if the changes in memory are to be discarded.
这篇关于在LINQ到SQL和SaveChanges的实体框架的SubmitChanges之间的技术区别是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!