What is the difference between Linq's SubmitChanges
and Entity Framework%% co?
WTablasDataContext.AfipEscalaSuss.Add(obj)
WTablasDataContext.AfipEscalaSuss.SubmitChanges(obj)
What is the difference between Linq's SubmitChanges
and Entity Framework%% co?
WTablasDataContext.AfipEscalaSuss.Add(obj)
WTablasDataContext.AfipEscalaSuss.SubmitChanges(obj)
When you execute SubmitChanges
, you save the changes in the context in the database. While Add(T entity)
adds the object to the track of the DbContext adding a state that is ready to be inserted but does not save it in the database until when the method SaveChanges()
is executed.
You are mixing two different things:
The Add
in LINQ To SQL and Entity Framework add an entity to the context so they are marked to be inserted after their changes persist.
SubmitChanges
of LINQ To SQL and SaveChanges
of Entity Framework just execute all the pending changes in the context against the database, that is, they generate the SQL corresponding to the changes and execute it.
Note: The LINQ To SQL
SubmitChanges
parameter is not an entity but aConflictMode
. This parameter is used to indicate what to do in case of conflict. The possible values are:FailOnFirstConflict
andContinueOnConflict