DataSet.ExtendedProperties 属性

获取与 DataSet 相关的自定义用户信息的集合。

**命名空间:**System.Data
**程序集:**System.Data(在 system.data.dll 中)

语法

声明
Public ReadOnly Property ExtendedProperties As PropertyCollection
用法
Dim instance As DataSet
Dim value As PropertyCollection

value = instance.ExtendedProperties
public PropertyCollection ExtendedProperties { get; }
public:
property PropertyCollection^ ExtendedProperties {
    PropertyCollection^ get ();
}
/** @property */
public PropertyCollection get_ExtendedProperties ()
public function get ExtendedProperties () : PropertyCollection

属性值

包含所有自定义用户信息的 PropertyCollection

备注

ExtendedProperties 属性允许您使用 DataSet 存储自定义信息。例如,您可能要存储数据应被刷新的时间。

如果您希望在以 XML 形式写入 DataSet 时保持扩展属性,则扩展属性必须采用 String 类型。

示例

下面的示例将自定义属性添加到由 ExtendedProperties 属性返回的 PropertyCollection 中。第二个示例检索该自定义属性。

Private Sub DemonstrateEnforceConstraints()
    ' Create a DataSet with one table, one column and 
    ' a UniqueConstraint.
    Dim dataSet As DataSet = New DataSet("dataSet")
    Dim table As DataTable = New DataTable("table")
    Dim column As DataColumn = New DataColumn("col1")
    column.Unique = True
    table.Columns.Add(column)
    dataSet.Tables.Add(table)
    Console.WriteLine("constraints.count: " _
        & table.Constraints.Count)

    ' add five rows.
    Dim row As DataRow
    Dim i As Integer
    For i = 0 To 4
       row = table.NewRow()
       row("col1") = i
       table.Rows.Add(row)
    Next
    table.AcceptChanges()
     
    dataSet.EnforceConstraints = False
    ' Change the values of all rows to 1.
    Dim thisRow As DataRow
    For Each thisRow In table.rows
       thisRow("col1") = 1
    Next
 
    Try
        dataSet.EnforceConstraints = True
    Catch e As System.Data.ConstraintException
        ' Process exception and return.
        Console.WriteLine("Exception of type {0} occurred.", _
            e.GetType().ToString())
    End Try
End Sub
private void DemonstrateEnforceConstraints()
{
    // Create a DataSet with one table, one column and 
    // a UniqueConstraint.
    DataSet dataSet= new DataSet("dataSet");
    DataTable table = new DataTable("table");
    DataColumn column = new DataColumn("col1");

    // A UniqueConstraint is added when the Unique 
    // property is true.
    column.Unique=true;
    table.Columns.Add(column);
    dataSet.Tables.Add(table);
    Console.WriteLine("constraints.count: " + 
        table.Constraints.Count);

    // add five rows.
    DataRow row ;
    for(int i=0;i<5;i++)
    {
        row = table.NewRow();
        row["col1"] = i;
        table.Rows.Add(row);
    }
    table.AcceptChanges();

    dataSet.EnforceConstraints=false;
    // Change the values of all rows to 1.
    foreach(DataRow thisRow in table.Rows)
    {
        thisRow["col1"]=1;
        //Console.WriteLine("\table" + thisRow[0]);
    }
    try
    {
        dataSet.EnforceConstraints=true;
    }
    catch(System.Data.ConstraintException e)
    {
        // Process exception and return.
        Console.WriteLine("Exception of type {0} occurred.", 
            e.GetType());
    }
}

平台

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

请参见

参考

DataSet 类
DataSet 成员
System.Data 命名空间

其他资源

在 ADO.NET 中使用 DataSet