This documentation is archived and is not being maintained.
AssociationAttribute Class
Visual Studio 2008
Designates a property to represent a database association, such as a foreign key relationship.
Assembly: System.Data.Linq (in System.Data.Linq.dll)
Use this attribute to represent an association in a database, such as the relationship between a foreign key and a primary key.
In the following example, the Order class includes an AssociationAttribute attribute to associate Orders with Customers.
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
System.Object
System.Attribute
System.Data.Linq.Mapping.DataAttribute
System.Data.Linq.Mapping.AssociationAttribute
System.Attribute
System.Data.Linq.Mapping.DataAttribute
System.Data.Linq.Mapping.AssociationAttribute
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: