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 값이 Added, Modified 또는 Deleted인 경우 기본 버전은 Current입니다.For a DataRowState value of Added, Modified or Deleted, the default version is Current. DataRowState 값이 Detached인 경우 버전은 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.

적용 대상

추가 정보