DataRowVersion DataRowVersion DataRowVersion DataRowVersion Enum

定義

DataRow のバージョンを記述します。Describes the version of a DataRow.

public enum class DataRowVersion
public enum DataRowVersion
type DataRowVersion = 
Public Enum DataRowVersion
継承
DataRowVersionDataRowVersionDataRowVersionDataRowVersion

フィールド

Current Current Current Current 512

行には、現在の値が含まれています。The row contains current values.

Default Default Default Default 1536

DataRowState の既定のバージョン。The default version of DataRowState. DataRowState の値が AddedModified、または Deleted の場合、既定バージョンは Current です。For a DataRowState value of Added, Modified or Deleted, the default version is Current. DetachedDataRowState 値の場合、バージョンは Proposed です。For a DataRowState value of Detached, the version is Proposed.

Original Original Original Original 256

行には、元の値が含まれています。The row contains its original values.

Proposed Proposed Proposed Proposed 1024

行には、提案値が含まれています。The row contains a proposed value.

次の例のチェック、DataRowVersionDataRowを呼び出す前に、AcceptChangesメソッド。The following example checks the DataRowVersion of a DataRow before invoking the AcceptChanges method.

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;
}
Private Sub CheckVersionBeforeAccept()
    'Run a function to create a DataTable with one column.
    Dim dataTable As DataTable = MakeTable()

    Dim dataRow As 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) Then
        If dataRow(0, DataRowVersion.Current) Is dataRow(0, DataRowVersion.Proposed) Then
            Console.WriteLine("The original and the proposed are the same.")
            dataRow.CancelEdit()
        Else
            dataRow.AcceptChanges()
            Console.WriteLine("The original and the proposed are different.")
        End If
    End If
End Sub

Private Function MakeTable() As DataTable
    ' Make a simple table with one column.
    Dim dt As New DataTable("dataTable")
    Dim firstName As New DataColumn("FirstName", _
       Type.GetType("System.String"))
    dt.Columns.Add(firstName)
    Return dt
End Function

注釈

DataRowVersionで見つかった値を取得するときに値が使用されます、DataRowを使用してItem[String, DataRowVersion]またはGetChildRowsDataRowオブジェクト。The DataRowVersion values are used when retrieving the value found in a DataRow using Item[String, DataRowVersion] or the GetChildRows of the DataRow object.

DataRowVersionのバージョンに通知する、DataRow存在します。The DataRowVersion informs you what version of a DataRow exists. バージョンは、次の状況で変更します。Versions change under the following circumstances:

  • 呼び出した後、DataRowオブジェクトのBeginEdit、値を変更する場合、メソッド、CurrentProposed値が使用可能になります。After calling the DataRow object's BeginEdit method, if you change the value, the Current and Proposed values become available.

  • 呼び出した後、DataRowオブジェクトのCancelEditメソッド、Proposedの値を削除します。After calling the DataRow object's CancelEdit method, the Proposed value is deleted.

  • 呼び出した後、DataRowオブジェクトのEndEditメソッド、提案された値になります、Current値。After calling the DataRow object's EndEdit method, the Proposed value becomes the Current value.

  • 呼び出した後、DataRowオブジェクトのAcceptChangesメソッド、Originalと同じ値になります、Current値。After calling the DataRow object's AcceptChanges method, the Original value becomes identical to the Current value.

  • 呼び出した後、DataTableオブジェクトのAcceptChangesメソッド、Originalと同じ値になります、Current値。After calling the DataTable object's AcceptChanges method, the Original value becomes identical to the Current value.

  • 呼び出した後、DataRowオブジェクトのRejectChangesメソッド、Proposed値は破棄され、バージョンがCurrentします。After calling the DataRow object's RejectChanges method, the Proposed value is discarded, and the version becomes Current.

適用対象

こちらもご覧ください