RelationshipManager.GetRelatedReference<TTargetEntity> Method (String, String)
Gets the EntityReference<TEntity> for a related object by using the specified combination of relationship name and target role name.
Assembly: EntityFramework (in EntityFramework.dll)
public EntityReference<TTargetEntity> GetRelatedReference<TTargetEntity>( string relationshipName, string targetRoleName ) where TTargetEntity : class
Parameters
- relationshipName
-
Type:
System.String
Name of the relationship to navigate. The relationship name is not namespace qualified.
- targetRoleName
-
Type:
System.String
Name of the target role for the navigation. Indicates the direction of navigation across the relationship.
Return Value
Type: System.Data.Entity.Core.Objects.DataClasses.EntityReference<TTargetEntity>The EntityReference<TEntity> of a related object.
Type Parameters
- TTargetEntity
The type of the returned EntityReference<TEntity>.
Exception | Condition |
---|---|
InvalidOperationException | The specified role returned an EntityCollection<TEntity> instead of an EntityReference<TEntity> . |