我正在编写代码来模拟我的 winforms over datasets 应用程序中的工作单元模式。
我有以下内容:
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 对象。
最佳答案
据我所知,没有。
要摆脱魔法字符串,你可以这样做
modified.Tables[0].Rows[0][Tables[0].CostUnitColumn.ColumnName, DataRowVersion.Current]
关于c# - 如何访问强类型 DataRow 的原始版本和修改版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6783100/