Linq to SQL: getting old values of changed rows
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 c开发者_如何学JAVAontext.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?
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.
Randy
精彩评论