RelationshipManager.GetAllRelatedEnds メソッド

定義

リレーションシップ マネージャーによって管理されているすべての関連する端の列挙を返します。

public:
 System::Collections::Generic::IEnumerable<System::Data::Objects::DataClasses::IRelatedEnd ^> ^ GetAllRelatedEnds();
public System.Collections.Generic.IEnumerable<System.Data.Objects.DataClasses.IRelatedEnd> GetAllRelatedEnds();
member this.GetAllRelatedEnds : unit -> seq<System.Data.Objects.DataClasses.IRelatedEnd>
Public Function GetAllRelatedEnds () As IEnumerable(Of IRelatedEnd)
Public Iterator Function GetAllRelatedEnds () As IEnumerable(Of IRelatedEnd)

返品

IRelatedEndを実装するオブジェクトのIEnumerable<T>。 リレーションシップがまだ設定されていない場合は、空の列挙が返されます。

次の使用例は、Contact エンティティに新しいSalesOrderHeader エンティティを追加します。 次に、 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);
    }
}

注釈

GetAllRelatedEnds メソッドは、EntityCollection<TEntity>オブジェクトとEntityReference<TEntity> オブジェクトの列挙体を返します。 EntityCollection<TEntity> EntityReference<TEntity>は、RelatedEndから派生する具象型です。 RelatedEnd抽象クラスは、IRelatedEnd インターフェイスを実装します。

適用対象