Share via


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 System.Data.Entity.Core.Objects.DataClasses.EntityReference<TTargetEntity> GetRelatedReference<TTargetEntity> (string relationshipName, string targetRoleName) where TTargetEntity : class;
member this.GetRelatedReference : string * string -> System.Data.Entity.Core.Objects.DataClasses.EntityReference<'argetEntity (requires 'argetEntity : null)> (requires 'argetEntity : null)
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> .

Applies to