如何获取特定版本的数据集行?

时间:2022-12-25 22:57:44

using a dataset,each row has a method called hasVersion() which implies to me it keeps a copy of the original and current versions of that row. How can I get one of the original row values?

使用数据集,每一行都有一个名为hasVersion()的方法,这意味着它保留了该行的原始版本和当前版本的副本。如何获取原始行值之一?

I'd imagine it's possible to call reject changes on that row and then check the value, but I'd rather not lose the changes, just read the value(s).

我想可以在该行上调用拒绝更改然后检查该值,但我不想丢失更改,只需读取值即可。

1 个解决方案

#1


If you are looking at a particular row, you can get a particular version of the row's values through the DataRowVersion enumeration thru one of the overloads, e.g.

如果您正在查看特定行,则可以通过DataRowVersion枚举通过其中一个重载获取行值的特定版本,例如:

SomeDataRow[0, DataRowVersion.Original] //by index
SomeDataRow["ColumnName", DataRowVersion.Original] //by column name

Along with that, you might want to use the GetChanges() method on the datatable. Pass in a DataRowState (in your case, DataRowState.Modified), then use the above to get the original value of any rows that have changed.

除此之外,您可能希望在数据表上使用GetChanges()方法。传入DataRowState(在您的情况下,DataRowState.Modified),然后使用上面的内容来获取已更改的任何行的原始值。

#1


If you are looking at a particular row, you can get a particular version of the row's values through the DataRowVersion enumeration thru one of the overloads, e.g.

如果您正在查看特定行,则可以通过DataRowVersion枚举通过其中一个重载获取行值的特定版本,例如:

SomeDataRow[0, DataRowVersion.Original] //by index
SomeDataRow["ColumnName", DataRowVersion.Original] //by column name

Along with that, you might want to use the GetChanges() method on the datatable. Pass in a DataRowState (in your case, DataRowState.Modified), then use the above to get the original value of any rows that have changed.

除此之外,您可能希望在数据表上使用GetChanges()方法。传入DataRowState(在您的情况下,DataRowState.Modified),然后使用上面的内容来获取已更改的任何行的原始值。