本文整理汇总了C#中System.Data.DataRowVersion枚举的典型用法代码示例。如果您正苦于以下问题:C# DataRowVersion枚举的具体用法?C# DataRowVersion怎么用?C# DataRowVersion使用的例子?那么恭喜您, 这里精选的枚举代码示例或许可以为您提供帮助。
在下文中一共展示了DataRowVersion枚举的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckVersionBeforeAccept
private static void CheckVersionBeforeAccept()
{
//Run a function to create a DataTable with one column.
DataTable dataTable = MakeTable();
DataRow dataRow = dataTable.NewRow();
dataRow["FirstName"] = "Marcy";
dataTable.Rows.Add(dataRow);
dataRow.BeginEdit();
// Edit data but keep the same value.
dataRow[0] = "Marcy";
// Uncomment the following line to add a new value.
// dataRow(0) = "Richard"
Console.WriteLine(string.Format("FirstName {0}", dataRow[0]));
// Compare the proposed version with the current.
if (dataRow.HasVersion(DataRowVersion.Proposed)) {
if (object.ReferenceEquals(dataRow[0, DataRowVersion.Current], dataRow[0, DataRowVersion.Proposed])) {
Console.WriteLine("The original and the proposed are the same.");
dataRow.CancelEdit();
} else {
dataRow.AcceptChanges();
Console.WriteLine("The original and the proposed are different.");
}
}
}
private static DataTable MakeTable()
{
// Make a simple table with one column.
DataTable dt = new DataTable("dataTable");
DataColumn firstName = new DataColumn("FirstName", Type.GetType("System.String"));
dt.Columns.Add(firstName);
return dt;
}