RelationshipManager.GetAllRelatedEnds メソッド

定義

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

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)

戻り値

IEnumerable<T> を実装するオブジェクトの 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);
    }
}

注釈

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

適用対象