RelationshipManager クラス

定義

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

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

次の使用例は、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);
    }
}

注釈

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

メソッド

名前 説明
Create(IEntityWithRelationships)

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

Equals(Object)

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

(継承元 Object)
GetAllRelatedEnds()

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

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)

適用対象