Ali Adlavaran
Ali Adlavaran

Reputation: 3735

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?

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

Are there any another differences?

Thanks

Upvotes: 23

Views: 20159

Answers (1)

Bas Slagter
Bas Slagter

Reputation: 9929

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.

Upvotes: 38

Related Questions