简体   繁体   English

Linq-to-SQL中的SubmitChanges和Entity Framework中的SaveChanges之间的技术差异是什么?

[英]What is technical difference between SubmitChanges in Linq-to-SQL and SaveChanges in Entity Framework?

What is technical difference between SubmitChanges in Linq-to-SQL and SaveChanges in Entity Framework? Linq-to-SQL中的SubmitChanges和Entity Framework中的SaveChanges之间的技术差异是什么?

We know SubmitChanges is a concept for DataContext class while SaveChanges is a method of ObjectContext . 我们知道SubmitChangesDataContext类的概念,而SaveChangesObjectContext一个方法。

Are there any another differences? 还有其他差异吗?

Thanks 谢谢

From MSDN: 来自MSDN:

SaveChanges operates within a transaction. SaveChanges在交易中运作。 SaveChanges will roll back that transaction and throw an exception if any of the dirty ObjectStateEntry objects cannot be persisted 如果无法保留任何脏ObjectStateEntry对象,SaveChanges将回滚该事务并抛出异常

SubmitChanges starts a transaction and will roll back if an exception occurs while SubmitChanges is executing. SubmitChanges启动一个事务,如果在SubmitChanges执行时发生异常,它将回滚。 However, this does not roll back the changes in memory or tracked by the DataContext; 但是,这不会回滚内存中的更改或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. 如果要丢弃内存中的更改,则可以从DataContext的新实例开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM