Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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

We know SubmitChanges is a concept for DataContext class while SaveChanges is a method of ObjectContext.

Are there any another differences?

Thanks

like image 690
Ali Adlavaran Avatar asked Jun 11 '12 13:06

Ali Adlavaran


1 Answers

From MSDN:

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 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.

like image 163
Bas Slagter Avatar answered Oct 05 '22 04:10

Bas Slagter