RelationshipManager.GetRelatedReference<TTargetEntity> Method

Definition

Gets the EntityReference<TEntity> for a related object by using the specified combination of relationship name and target role name.

public:
generic <typename TTargetEntity>
 where TTargetEntity : class, System::Data::Objects::DataClasses::IEntityWithRelationships System::Data::Objects::DataClasses::EntityReference<TTargetEntity> ^ GetRelatedReference(System::String ^ relationshipName, System::String ^ targetRoleName);
public:
generic <typename TTargetEntity>
 where TTargetEntity : class System::Data::Objects::DataClasses::EntityReference<TTargetEntity> ^ GetRelatedReference(System::String ^ relationshipName, System::String ^ targetRoleName);
public System.Data.Objects.DataClasses.EntityReference<TTargetEntity> GetRelatedReference<TTargetEntity> (string relationshipName, string targetRoleName) where TTargetEntity : class, System.Data.Objects.DataClasses.IEntityWithRelationships;
public System.Data.Objects.DataClasses.EntityReference<TTargetEntity> GetRelatedReference<TTargetEntity> (string relationshipName, string targetRoleName) where TTargetEntity : class;
member this.GetRelatedReference : string * string -> System.Data.Objects.DataClasses.EntityReference<'argetEntity (requires 'argetEntity : null and 'argetEntity :> System.Data.Objects.DataClasses.IEntityWithRelationships)> (requires 'argetEntity : null and 'argetEntity :> System.Data.Objects.DataClasses.IEntityWithRelationships)
member this.GetRelatedReference : string * string -> System.Data.Objects.DataClasses.EntityReference<'argetEntity (requires 'argetEntity : null)> (requires 'argetEntity : null)
Public Function GetRelatedReference(Of TTargetEntity As {Class, IEntityWithRelationships}) (relationshipName As String, targetRoleName As String) As EntityReference(Of TTargetEntity)
Public Function GetRelatedReference(Of TTargetEntity As Class) (relationshipName As String, targetRoleName As String) As EntityReference(Of TTargetEntity)

Type Parameters

TTargetEntity

The type of the returned EntityReference<TEntity>.

Parameters

relationshipName
String

Name of the relationship to navigate. The relationship name is not namespace qualified.

targetRoleName
String

Name of the target role for the navigation. Indicates the direction of navigation across the relationship.

Returns

EntityReference<TTargetEntity>

The EntityReference<TEntity> of a related object.

Exceptions

The specified role returned an EntityCollection<TEntity> instead of an EntityReference<TEntity>.

Remarks

The relationship name should not be namespace qualified. An error occurs when you prepend the namespace to the relationship name.

Applies to