MetaJoinTableAssociation
The MetaJoinTableAssociation class represents a join table association in the Telerik Data Access metadata model. It derives from the MetaAssociation class. The MetaJoinTableAssociation class describes many-to-many associations between two classes and gives the following information:
- JoinTable - gets the join table used by the current association.
- FromConstraintName - gets the name of the foreign key constraint that is used to enforce the 'from end' of the association.
- ToConstraintName - gets the name of the foreign key constraint that is used to enforce the 'to end' of the association.
- KeyConstraintName - gets the name of the foreign key constraint that is used to associate the key values of this association with the join table.
- SequenceColumn - gets the sequence column for the join table used by the current association.
The following example shows you how to access all many-to-many associations from your model:
private string GetMetaJoinTableAssociations(Telerik.OpenAccess.Metadata
.MetadataContainer container)
{
StringBuilder sb = new StringBuilder();
foreach (MetaAssociation metaAssociation in container.Associations)
{
sb.AppendFormat("\nType: {0}", metaAssociation.AssociationType);
MetaJoinTableAssociation manyToMany = metaAssociation as MetaJoinTableAssociation;
if (manyToMany == null)
{
continue;
}
sb.AppendFormat("\n\tSource: {0}", manyToMany.Source.Name);
sb.AppendFormat("\n\tTarget: {0}", manyToMany.Target.Name);
}
return sb.ToString();
}
Private Function GetMetaJoinTableAssociations(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)
Dim manyToMany As MetaJoinTableAssociation = TryCast(_metaAssociation, MetaJoinTableAssociation)
If manyToMany Is Nothing Then
Continue For
End If
sb.AppendFormat(vbLf & vbTab & "Source: {0}", manyToMany.Source.Name)
sb.AppendFormat(vbLf & vbTab & "Target: {0}", manyToMany.Target.Name)
Next _metaAssociation
Return sb.ToString()
End Function