DataRowVersion 열거형

정의

DataRow의 버전을 설명합니다.

public enum class DataRowVersion
public enum DataRowVersion
type DataRowVersion = 
Public Enum DataRowVersion
상속
DataRowVersion

필드

Current 512

행에 현재 값이 포함됩니다.

Default 1536

DataRowState의 기본 버전입니다. DataRowState 값이 Added, Modified 또는 Deleted인 경우 기본 버전은 Current입니다. DataRowState 값이 Detached인 경우 버전은 Proposed입니다.

Original 256

행에 원래 값이 포함됩니다.

Proposed 1024

행에 제안된 값이 포함됩니다.

예제

다음 예제에서는 확인 합니다 DataRowVersionDataRow 를 호출하기 AcceptChanges 전에 메서드.

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 using Item[] 또는 GetChildRows 에 있는 DataRow 값을 검색할 때 사용됩니다.

DataRowVersion 존재하는 버전을 DataRow 알려줍니다. 버전은 다음과 같은 경우에 변경됩니다.

  • 개체의 BeginEdit 메서드를 호출한 DataRow 후 값을 Current 변경하면 및 Proposed 값을 사용할 수 있게 됩니다.

  • 개체의 CancelEdit 메서드를 DataRow 호출하면 값이 Proposed 삭제됩니다.

  • 개체의 EndEdit 메서드를 DataRow 호출하면 제안 값이 값이 Current 됩니다.

  • 개체의 메서드를 DataRow 호출하면 값이 Original 값과 동일합니다Current.AcceptChanges

  • 개체의 메서드를 DataTable 호출하면 값이 Original 값과 동일합니다Current.AcceptChanges

  • 개체의 메서드를 DataRow 호출하면 값이 Proposed 삭제되고 버전이 가 됩니다Current.RejectChanges

적용 대상

추가 정보