RelatedEnd.TargetRoleName Propriété

Définition

Obtient le nom du rôle à la terminaison cible de la relation.Gets the role name at the target end of the relationship.

public:
 property System::String ^ TargetRoleName { System::String ^ get(); };
public string TargetRoleName { get; }
member this.TargetRoleName : string
Public ReadOnly Property TargetRoleName As String

Valeur de propriété

String qui correspond au nom de rôle.A String that is the role name.

Implémente

Exemples

L’exemple de cette rubrique est basé sur le modèle de vente AdventureWorks Sales Model.The example in this topic is based on the AdventureWorks Sales Model. L’exemple ajoute de SalesOrderHeader nouvelles entités à Contact l’entité.The example adds new SalesOrderHeader entities to the Contact entity. Il obtient ensuite toutes les terminaisons connexes Contact de l’entité et affiche le nom de la relation, le nom du rôle source et le nom du rôle cible pour chaque terminaison connexe.Then it gets all related ends from the Contact entity and displays relationship name, source role name, and target role name for each related end.

using (AdventureWorksEntities context =
    new AdventureWorksEntities())
{
    Contact contact = new Contact();

    // Create a new SalesOrderHeader.
    SalesOrderHeader newSalesOrder1 = new SalesOrderHeader();
    // Add SalesOrderHeader to the Contact.
    contact.SalesOrderHeaders.Add(newSalesOrder1);

    // Create another SalesOrderHeader.
    SalesOrderHeader newSalesOrder2 = new SalesOrderHeader();
    // Add SalesOrderHeader to the Contact.
    contact.SalesOrderHeaders.Add(newSalesOrder2);

    // Get all related ends
    IEnumerable<IRelatedEnd> relEnds =
        ((IEntityWithRelationships)contact).RelationshipManager
        .GetAllRelatedEnds();

    foreach (IRelatedEnd relEnd in relEnds)
    {
        Console.WriteLine("Relationship Name: {0}", relEnd.RelationshipName);
        Console.WriteLine("Source Role Name: {0}", relEnd.SourceRoleName);
        Console.WriteLine("Target Role Name: {0}", relEnd.TargetRoleName);
    }
}
Using context As New AdventureWorksEntities()
    Dim contact As New Contact()

    ' Create a new SalesOrderHeader. 
    Dim newSalesOrder1 As New SalesOrderHeader()
    ' Add SalesOrderHeader to the Contact. 
    contact.SalesOrderHeaders.Add(newSalesOrder1)

    ' Create another SalesOrderHeader. 
    Dim newSalesOrder2 As New SalesOrderHeader()
    ' Add SalesOrderHeader to the Contact. 
    contact.SalesOrderHeaders.Add(newSalesOrder2)

    ' Get all related ends 
    Dim relEnds As IEnumerable(Of IRelatedEnd) = DirectCast(contact, IEntityWithRelationships).RelationshipManager.GetAllRelatedEnds()

    For Each relEnd As IRelatedEnd In relEnds
        Console.WriteLine("Relationship Name: {0}", relEnd.RelationshipName)
        Console.WriteLine("Source Role Name: {0}", relEnd.SourceRoleName)
        Console.WriteLine("Target Role Name: {0}", relEnd.TargetRoleName)
    Next
End Using

Remarques

Le nom de rôle est spécifié par Role l’attribut de End l’élément dans l’Association qui définit cette relation dans le modèle conceptuel.The role name is specified by the Role attribute of the End element in the association that defines this relationship in the conceptual model. Pour plus d’informations, consultez Association, élément (CSDL).For more information, see Association Element (CSDL).

S’applique à

Voir aussi