Linq to SQL:获取已更改行的旧值 [英] Linq to SQL: getting old values of changed rows

查看:70
本文介绍了Linq to SQL:获取已更改行的旧值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个绑定到Linq to SQL表的可编辑网格.我使用SubmitChanges保存更改,并且需要一种方法来获取已更改行的旧值.我尝试获取context.GetChangeSet().Updates,但是问题在于,即使在调用SubmitChanges()之前,此集合中的行也具有新值而不是旧值.我该怎么办?

I have an editable grid bound to a Linq to SQL table. I use SubmitChanges to save changes and I need a way to get old values of the changed rows. I tried getting context.GetChangeSet().Updates but the problem is the rows in this collection has new values not the old ones, even before calling SubmitChanges(). How can I do this?

推荐答案

L2S缓存将包含旧值.即使在您调用SubmitChanges()之后.我发现这很困难.缓存将包含旧值,直到您调用context.Refresh()刷新所有行.因此,您可以简单地重新获取值. L2S将从缓存中获取它们,这将是旧值.

The L2S cache will contain the old values. Even after you call SubmitChanges(). I found this out the hard way. The cache will contain the old values until you call context.Refresh() to refresh all the rows. So, you can simply re-retrieve the values. L2S will get them from cache, which will be the old values.

兰迪

这篇关于Linq to SQL:获取已更改行的旧值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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