本文整理匯總了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;
}