共用方式為


IRelatedEnd.RelationshipName 屬性

定義

取得這個相關端所參與之關聯性的名稱。

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

屬性值

這個 IRelatedEnd 所參與之關聯性的名稱。 此關聯性名稱不符合命名空間。

範例

下列範例會將新的 SalesOrderHeader 實體新增至 Contact 實體。 然後它會從 Contact 實體取得所有相關的結尾,並顯示每個相關端的關聯性名稱、來源角色名稱和目標角色名稱。

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);
    }
}

適用於