Data Access has been discontinued. Please refer to this page for more information.

MetaAssociation

This article is relevant to entity models that utilize the deprecated Visual Studio integration of Telerik Data Access. The current documentation of the Data Access framework is available here.

The abstract MetaAssociation class represents an association in the Telerik Data Access metadata model. Two required properties (Source and Target) specify the persistent types at the ends of the association. Respectively, the SourceEnd and TargetEnd properties specify the navigation members (e.g. product.Category and category.Products).

The type of the association is specified via the AssociationType property. The values for this property are predefined in the AssociationType enumeration, which exposes the following fields:

  • Reference
  • Collection
  • OneToMany
  • ManyToMany
  • OneToManyJointable
  • ManyToManyJointable
  • DictionaryJointable

The table columns that participate in the association in the underlying database could be accessed via the AssociationParts property. The MetaAssociationPart represents a part of a MetaAssociation definition. The MetaAssociationPart provides information about the foreign key and identity columns from the underlying database that participate in the association (the IdentityColumn and ForeignKeyColumn properties). The IdentityMember and ForeignKeyMember properties represent the corresponding primary key and foreign key properties from the domain model.

The following example shows you how to access all associations from your domain model:

private string GetAssociations(Telerik.OpenAccess.Metadata.MetadataContainer container)
{
   StringBuilder sb = new StringBuilder();
   foreach (MetaAssociation metaAssociation in container.Associations)
   {
       sb.AppendFormat("\nType: {0}", metaAssociation.AssociationType);
       sb.AppendFormat("\n\tSource: {0}", metaAssociation.Source.Name);
       sb.AppendFormat("\n\tTarget: {0}", metaAssociation.Target.Name);
   }
   return sb.ToString();
}
Private Function GetAssociations(ByVal container As Telerik.OpenAccess.Metadata.MetadataContainer) As String
 Dim sb As New StringBuilder()
 For Each _metaAssociation As MetaAssociation In container.Associations
  sb.AppendFormat(vbLf & "Type: {0}", _metaAssociation.AssociationType)
  sb.AppendFormat(vbLf & vbTab & "Source: {0}", _metaAssociation.Source.Name)
  sb.AppendFormat(vbLf & vbTab & "Target: {0}", _metaAssociation.Target.Name)
 Next _metaAssociation
 Return sb.ToString()
End Function