DataRowVersion 열거형
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
DataRow버전을 설명합니다.
public enum class DataRowVersion
public enum DataRowVersion
type DataRowVersion =
Public Enum DataRowVersion
- 상속
필드
| Name | 값 | Description |
|---|---|---|
| Original | 256 | 행에는 원래 값이 포함됩니다. |
| Current | 512 | 행에 현재 값이 포함됩니다. |
| Proposed | 1024 | 행에 제안된 값이 포함됩니다. |
| Default | 1536 | 의 기본 버전입니다 DataRowState.
|
예제
다음 예제에서는 메서드를 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 호출한 후 값을 변경하면 값
Current과Proposed값을 사용할 수 있게 BeginEdit 됩니다.개체의 CancelEdit 메서드를 DataRow 호출하면 값이
Proposed삭제됩니다.개체의 메서드를 DataRow 호출하면
Original값이 값과 동일합니다Current.AcceptChanges개체의 메서드를 DataTable 호출하면
Original값이 값과 동일합니다Current.AcceptChanges개체의 메서드를 DataRow 호출하면 값이
Proposed삭제되고 버전이 됩니다Current.RejectChanges