如何访问强类型DataRow的原始版本和修改版本?

时间:2011-07-21 21:34:33

标签: c# dataset strongly-typed-dataset unit-of-work

我正在编写代码来模拟我的winforms数据集应用程序中的工作模式单元。

我有以下内容:

foreach (EomApp1.Formss.Accounting.Data.AccountingView.AccountingViewRow 
                in accountingView.GetChanges(DataRowState.Modified).Tables[0].Rows)
            {
                 // break point -> immediate window

即时窗口:

modified.Tables[0].Rows[0]["Cost/Unit", DataRowVersion.Original]
1
modified.Tables[0].Rows[0]["Cost/Unit", DataRowVersion.Current]
0

有没有办法使用强类型数据集访问上述信息? (在我的例子中,accountingView ,但我不知道如何在不使用列的字符串名称的情况下获取更改的DataRowVersion对象。

2 个答案:

答案 0 :(得分:3)

据我所知,没有 要摆脱你可以做的魔术弦

modified.Tables[0].Rows[0][Tables[0].CostUnitColumn.ColumnName, DataRowVersion.Current]

答案 1 :(得分:1)

System.Data.DataSetExtensions程序集中的DataRowExtensions.Field扩展方法是否为您解决了这个问题?请注意DataColumnDataRowVersion的参数。