DataRowView.RowVersion 속성
DataRow에 대한 현재 버전 설명을 가져옵니다.
네임스페이스: System.Data
어셈블리: System.Data(system.data.dll)
구문
‘선언
Public ReadOnly Property RowVersion As DataRowVersion
‘사용 방법
Dim instance As DataRowView
Dim value As DataRowVersion
value = instance.RowVersion
public DataRowVersion RowVersion { get; }
public:
property DataRowVersion RowVersion {
DataRowVersion get ();
}
/** @property */
public DataRowVersion get_RowVersion ()
public function get RowVersion () : DataRowVersion
속성 값
DataRowVersion 값 중 하나입니다. RowVersion 속성의 가능한 값은 Default, Original, Current 및 Proposed입니다.
설명
RowStateFilter 속성은 DataRowState 및 DataRowVersion 설정을 지정합니다. 자세한 내용은 DataRowState, DataRowVersion 및 DataViewRowState를 참조하십시오.
예제
다음 예제에서는 RowVersion 속성을 사용하여 DataRowView에 있는 행의 상태를 확인합니다.
Private Sub DemonstrateRowVersion()
Dim i As Integer
' Create a DataTable with one column.
Dim table As New DataTable("Table")
Dim column As New DataColumn("Column")
table.Columns.Add(column)
' Add ten rows.
Dim row As DataRow
For i = 0 To 9
row = table.NewRow()
row("Column") = "item " + i.ToString()
table.Rows.Add(row)
Next i
table.AcceptChanges()
' Create a DataView with the table.
Dim view As New DataView(table)
' Change one row's value:
table.Rows(1)("Column") = "Hello"
' Add one row:
row = table.NewRow()
row("Column") = "World"
table.Rows.Add(row)
' Set the RowStateFilter to display only added and modified rows.
view.RowStateFilter = _
DataViewRowState.Added Or DataViewRowState.ModifiedCurrent
' Print those rows. Output includes "Hello" and "World".
PrintView(view, "ModifiedCurrent and Added")
' Set filter to display only originals of modified rows.
view.RowStateFilter = DataViewRowState.ModifiedOriginal
PrintView(view, "ModifiedOriginal")
' Delete three rows.
table.Rows(1).Delete()
table.Rows(2).Delete()
table.Rows(3).Delete()
' Set the RowStateFilter to display only deleted rows.
view.RowStateFilter = DataViewRowState.Deleted
PrintView(view, "Deleted")
' Set filter to display only current rows.
view.RowStateFilter = DataViewRowState.CurrentRows
PrintView(view, "Current")
' Set filter to display only unchanged rows.
view.RowStateFilter = DataViewRowState.Unchanged
PrintView(view, "Unchanged")
' Set filter to display only original rows.
' Current values of unmodified rows are also returned.
view.RowStateFilter = DataViewRowState.OriginalRows
PrintView(view, "OriginalRows")
End Sub
Private Sub PrintView(ByVal view As DataView, ByVal label As String)
Console.WriteLine(ControlChars.Cr + label)
Dim i As Integer
For i = 0 To view.Count - 1
Console.WriteLine(view(i)("Column"))
Console.WriteLine("DataRowView.RowVersion: {0}", _
view(i).RowVersion)
Next i
End Sub
private static void DemonstrateRowVersion()
{
// Create a DataTable with one column.
DataTable table = new DataTable("Table");
DataColumn column = new DataColumn("Column");
table.Columns.Add(column);
// Add ten rows.
DataRow row;
for (int i = 0; i < 10; i++)
{
row = table.NewRow();
row["Column"] = "item " + i;
table.Rows.Add(row);
}
table.AcceptChanges();
// Create a DataView with the table.
DataView view = new DataView(table);
// Change one row's value:
table.Rows[1]["Column"] = "Hello";
// Add one row:
row = table.NewRow();
row["Column"] = "World";
table.Rows.Add(row);
// Set the RowStateFilter to display only added
// and modified rows.
view.RowStateFilter = DataViewRowState.Added |
DataViewRowState.ModifiedCurrent;
// Print those rows. Output includes "Hello" and "World".
PrintView(view, "ModifiedCurrent and Added");
// Set filter to display only originals of modified rows.
view.RowStateFilter = DataViewRowState.ModifiedOriginal;
PrintView(view, "ModifiedOriginal");
// Delete three rows.
table.Rows[1].Delete();
table.Rows[2].Delete();
table.Rows[3].Delete();
// Set the RowStateFilter to display only deleted rows.
view.RowStateFilter = DataViewRowState.Deleted;
PrintView(view, "Deleted");
// Set filter to display only current rows.
view.RowStateFilter = DataViewRowState.CurrentRows;
PrintView(view, "Current");
// Set filter to display only unchanged rows.
view.RowStateFilter = DataViewRowState.Unchanged;
PrintView(view, "Unchanged");
// Set filter to display only original rows.
// Current values of unmodified rows are also returned.
view.RowStateFilter = DataViewRowState.OriginalRows;
PrintView(view, "OriginalRows");
}
private static void PrintView(DataView view, string label)
{
Console.WriteLine("\n" + label);
for (int i = 0; i < view.Count; i++)
{
Console.WriteLine(view[i]["Column"]);
Console.WriteLine("DataViewRow.RowVersion: {0}",
view[i].RowVersion);
}
}
플랫폼
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.
버전 정보
.NET Framework
2.0, 1.1, 1.0에서 지원
.NET Compact Framework
2.0, 1.0에서 지원
참고 항목
참조
DataRowView 클래스
DataRowView 멤버
System.Data 네임스페이스
AcceptChanges
BeginEdit
DataRowVersion 열거형
EndEdit