DataRowVersion 열거형

정의

DataRow의 버전을 설명합니다.Describes the version of a DataRow.

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

필드

Current 512

행에 현재 값이 포함됩니다.The row contains current values.

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 256

행에 원래 값이 포함됩니다.The row contains its original values.

Proposed 1024

행에 제안된 값이 포함됩니다.The row contains a proposed value.

예제

다음 예제에서는 DataRowVersion DataRow 메서드를 호출 하기 전에의를 확인 합니다 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[] 개체의 또는을 사용 하 여에서 찾은 값을 검색할 때 사용 됩니다 GetChildRows DataRow .The DataRowVersion values are used when retrieving the value found in a DataRow using Item[] 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 값을 변경 하면 Current 및 값을 Proposed 사용할 수 있게 됩니다.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 AcceptChangesOriginal 값과 동일 하 게 됩니다 Current .After calling the DataRow object's AcceptChanges method, the Original value becomes identical to the Current value.

  • 개체의 메서드를 호출한 후 값 DataTable AcceptChangesOriginal 값과 동일 하 게 됩니다 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.

적용 대상

추가 정보