RelationshipManager::GetRelatedReference<TTargetEntity> Method (String^, String^)
.NET Framework (current version)
Gets the EntityReference<TEntity> for a related object by using the specified combination of relationship name and target role name.
Assembly: System.Data.Entity (in System.Data.Entity.dll)
public: generic<typename TTargetEntity> where TTargetEntity : ref class EntityReference<TTargetEntity>^ GetRelatedReference( String^ relationshipName, String^ targetRoleName )
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.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>. |
The relationship name should not be namespace qualified. An error occurs when you prepend the namespace to the relationship name.
.NET Framework
Available since 3.5
Available since 3.5
Show: