问题
Hello guys as you can see on my Title, I am wondering what is more safe and more stable to use when we are talkin about Linq to SQL, SubmitChanges() method or .Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, "entity to update"), because obliviosly we need to use them everytime we are making changes on database table, thats true?
Because in case we are not using them, we will never had updated database model in our IDE (for example visual studio).
I just started working with linq to sql and I WANT TO understand both helpers, why should I or why should not I use any of them.
Thanks guys, Cheers
回答1:
The two methods do incomparable things. SubmitChanges
writes to the database and Refresh
reads from the database.
Refresh
is pretty much never needed because normally you are making all writes through entities. This means that the entities are always up to date.
来源:https://stackoverflow.com/questions/39831093/linq-to-sql-submit-changes-or-refreshsystem-data-linq-refreshmode-overwrite