DataSet.ShouldSerializeRelations 方法

定义

获取一个值,该值指示是否应该保持 Relations 属性。Gets a value indicating whether Relations property should be persisted.

protected:
 virtual bool ShouldSerializeRelations();
protected virtual bool ShouldSerializeRelations ();
abstract member ShouldSerializeRelations : unit -> bool
override this.ShouldSerializeRelations : unit -> bool
Protected Overridable Function ShouldSerializeRelations () As Boolean

返回

如果已将属性值更改为其默认值之外的值,则为 true;否则为 falsetrue if the property value has been changed from its default; otherwise, false.

示例

下面的示例演示一个派生自 DataSet 类的类。The following examples show a class derived from the DataSet class. ResetShouldSerializeRelations 方法是从派生类中的函数中调用的。The Reset and ShouldSerializeRelations methods are invoked from within functions in the derived class.

public  class DerivedDataSet:System.Data.DataSet 
{
    public void ResetDataSetRelations()
    {
        // Check the ShouldSerializeRelations methods 
        // before invoking Reset.
        if(!this.ShouldSerializeRelations())
        {
            this.Reset();
        }
    }
}
Public Class DerivedDataSet
    Inherits System.Data.DataSet
    
    Public Sub ResetDataSetRelations()
        ' Check the ShouldSerializeRelations methods 
        ' before invoking Reset.
        If Not Me.ShouldSerializeRelations() Then
            Me.Reset()
        End If
    End Sub
End Class

注解

如果要为 DataSet创建设计器,或创建自己的包含 DataSet的控件,则通常使用此方法。You typically use this method if you are either creating a designer for the DataSet, or creating your own control incorporating the DataSet.

适用于

另请参阅