Linq to sql submit changes () or .Refresh(System.D

2019-09-19 00:48发布

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条回答
一纸荒年 Trace。
2楼-- · 2019-09-19 01:35

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.

查看更多
登录 后发表回答