Linq to sql submit changes () or .Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, “entity to update”)

▼魔方 西西 提交于 2019-12-25 08:18:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!