Linq to sql提交changes()或.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues,“entity to update”) [英] Linq to sql submit changes () or .Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, "entity to update")

查看:378
本文介绍了Linq to sql提交changes()或.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues,“entity to update”)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,你可以看到我的标题,我想知道什么是更安全和更稳定的使用,当我们谈论 Linq到SQL ,SubmitChanges()方法或
.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues,entity to update),因为每当我们对数据库表进行更改时,我们需要使用它们,这是真的吗?

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?

因为如果我们不使用它们,我们将永远不会在我们的IDE中更新数据库模型(例如visual studio)。

Because in case we are not using them, we will never had updated database model in our IDE (for example visual studio).

谢谢你们,
Cheers

Thanks guys, Cheers

推荐答案

这两种方法做了无与伦比的事情。 SubmitChanges 写入数据库,刷新从数据库读取。

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.

这篇关于Linq to sql提交changes()或.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues,“entity to update”)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆