RelationshipManager クラス

定義

オブジェクト間のリレーションシップを追跡するためにオブジェクト コンテキストで使用されます。

public ref class RelationshipManager
[System.Serializable]
public class RelationshipManager
[<System.Serializable>]
type RelationshipManager = class
Public Class RelationshipManager
継承
RelationshipManager
属性

次の使用例は、エンティティに新しい 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);
    }
}

注釈

RelationshipManager は、オブジェクト間のリレーションシップを追跡するためにオブジェクト コンテキストで使用されます。 オブジェクト コンテキストで追跡されるリレーションシップごとに、RelationshipManager クラスのインスタンスが 1 つあります。 リレーションシップは、概念モデルの関連付けによって定義されます。 詳細については、「Association 要素 (CSDL)」を参照してください。

メソッド

Create(IEntityWithRelationships)

新しい RelationshipManager オブジェクトを作成します。

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetAllRelatedEnds()

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

GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetRelatedCollection<TTargetEntity>(String, String)

指定されたリレーションシップ名とターゲット ロール名を持つ、関連オブジェクトの EntityCollection<TEntity> を取得します。

GetRelatedEnd(String, String)

リレーションシップに含まれる指定されたターゲット ロールの適切な型の EntityCollection<TEntity> または EntityReference<TEntity> を返します。

GetRelatedReference<TTargetEntity>(String, String)

指定されたリレーションシップ名とターゲット ロール名の組み合わせを使用して、関連オブジェクトの EntityReference<TEntity> を取得します。

GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
InitializeRelatedCollection<TTargetEntity>(String, String, EntityCollection<TTargetEntity>)

パラメーターなしのコンストラクターを使用して作成された既存の EntityCollection<TEntity> を初期化します。

InitializeRelatedReference<TTargetEntity>(String, String, EntityReference<TTargetEntity>)

パラメーターなしのコンストラクターを使用して作成された既存の EntityReference<TEntity> を初期化します。

MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
OnDeserialized(StreamingContext)

RelationshipManager インスタンスと共にエンティティ オブジェクトを逆シリアル化する目的で内部的に使用されます。

OnSerializing(StreamingContext)

シリアル化されたリレーションシップによる EntityKey のバイナリ シリアル化を準備するために、Object Services によって呼び出されます。

ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象