DataRowVersion 열거형

정의

DataRow버전을 설명합니다.

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

필드

Name Description
Original 256

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

Current 512

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

Proposed 1024

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

Default 1536

의 기본 버전입니다 DataRowState. DataRowState 또는 값의 DeletedAddedModified 경우 기본 버전은 .입니다.Current 값의 DataRowStateDetached경우 버전은 .입니다 Proposed.

예제

다음 예제에서는 메서드를 DataRowVersion 호출하기 전에 해당 DataRow 메서드를 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 using Item[] 또는 개체에서 찾은 DataRow 값을 검색할 GetChildRowsDataRow 때 사용됩니다.

어떤 DataRowVersion 버전의 존재가 DataRow 있는지 알려줍니다. 버전은 다음과 같은 경우에 변경됩니다.

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

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

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

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

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

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

적용 대상

추가 정보