AssociationAttribute クラス

定義

外部キー リレーションシップなど、データベースの関連付けを表すプロパティを指定します。

public ref class AssociationAttribute sealed : System::Data::Linq::Mapping::DataAttribute
[System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple=false)]
public sealed class AssociationAttribute : System.Data.Linq.Mapping.DataAttribute
[<System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple=false)>]
type AssociationAttribute = class
    inherit DataAttribute
Public NotInheritable Class AssociationAttribute
Inherits DataAttribute
継承
AssociationAttribute
属性

private EntityRef<Customer> _Customer;
// ...
[Association(Name="FK_Orders_Customers", Storage="_Customer", ThisKey="CustomerID", IsForeignKey=true)]
public Customer Customer
{
    get
    {
        return this._Customer.Entity;
    }
    set
    {
        Customer previousValue = this._Customer.Entity;
        if (((previousValue != value)
                    || (this._Customer.HasLoadedOrAssignedValue == false)))
        {
            this.SendPropertyChanging();
            if ((previousValue != null))
            {
                this._Customer.Entity = null;
                previousValue.Orders.Remove(this);
            }
            this._Customer.Entity = value;
            if ((value != null))
            {
                value.Orders.Add(this);
                this._CustomerID = value.CustomerID;
            }
            else
            {
                this._CustomerID = default(string);
            }
            this.SendPropertyChanged("Customer");
        }
    }
}
Private _Customer As EntityRef(Of Customer)
<Association(Name:="FK_Orders_Customers", Storage:="_Customer", ThisKey:="CustomerID", IsForeignKey:=True)> _
Public Property Customer() As Customer
    Get
        Return Me._Customer.Entity
    End Get
    Set(ByVal value As Customer)
        Dim previousValue As Customer = Me._Customer.Entity
        If (((previousValue Is value) _
           = False) _
           OrElse (Me._Customer.HasLoadedOrAssignedValue = False)) Then
            Me.SendPropertyChanging()
            If ((previousValue Is Nothing) _
               = False) Then
                Me._Customer.Entity = Nothing
                previousValue.Orders.Remove(Me)
            End If
            Me._Customer.Entity = value
            If ((value Is Nothing) _
               = False) Then
                value.Orders.Add(Me)
                Me._CustomerID = value.CustomerID
            Else
                Me._CustomerID = CType(Nothing, String)
            End If
            Me.SendPropertyChanged("Customer")
        End If
    End Set
End Property

注釈

外部キーと主キーの関係など、データベース内の関連付けを表すには、この属性を使用します。

次の例では、 クラスに Order Orders を AssociationAttribute Customers に関連付ける属性が含まれています。

コンストラクター

AssociationAttribute()

AssociationAttribute クラスの新しいインスタンスを初期化します。

プロパティ

DeleteOnNull

外部キー メンバーがすべて Null 非許容の一対一関連付けの場合、関連付けを Null に設定するとオブジェクトが削除されます。

DeleteRule

関連付けの削除動作を取得または設定します。

IsForeignKey

データベースのリレーションシップを表す関連付けで、メンバーを外部キーとして取得または設定します。

IsUnique

外部キーの一意性の制約を示す情報を取得または設定します。

Name

列の名前を取得または設定します。

(継承元 DataAttribute)
OtherKey

ターゲット エンティティ クラスの 1 つ以上のメンバーを、関連付けの他方の側のキー値として取得または設定します。

Storage

列からの値を保持するプライベート ストレージ フィールドを取得または設定します。

(継承元 DataAttribute)
ThisKey

関連付けのこちら側のキー値を表す、このエンティティ クラスのメンバーを取得または設定します。

TypeId

派生クラスで実装されると、この Attribute の一意の識別子を取得します。

(継承元 Attribute)

メソッド

Equals(Object)

このインスタンスが、指定されたオブジェクトと等価であるかどうかを示す値を返します。

(継承元 Attribute)
GetHashCode()

このインスタンスのハッシュ コードを返します。

(継承元 Attribute)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
IsDefaultAttribute()

派生クラスでオーバーライドされるとき、このインスタンスの値が派生クラスの既定値であるかどうかを示します。

(継承元 Attribute)
Match(Object)

派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。

(継承元 Attribute)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

明示的なインターフェイスの実装

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

一連の名前を対応する一連のディスパッチ識別子に割り当てます。

(継承元 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

オブジェクトの型情報を取得します。この情報はインターフェイスの型情報の取得に使用できます。

(継承元 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。

(継承元 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

オブジェクトによって公開されたプロパティおよびメソッドへのアクセスを提供します。

(継承元 Attribute)

適用対象