Entity.GetRelatedEntity<TEntity> Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the related entity instance for the specified relationship.
protected:
generic <typename TEntity>
where TEntity : Microsoft::Xrm::Sdk::Entity virtual TEntity GetRelatedEntity(System::String ^ relationshipSchemaName, Nullable<Microsoft::Xrm::Sdk::EntityRole> primaryEntityRole);
protected virtual TEntity GetRelatedEntity<TEntity> (string relationshipSchemaName, Microsoft.Xrm.Sdk.EntityRole? primaryEntityRole) where TEntity : Microsoft.Xrm.Sdk.Entity;
abstract member GetRelatedEntity : string * Nullable<Microsoft.Xrm.Sdk.EntityRole> -> 'Entity (requires 'Entity :> Microsoft.Xrm.Sdk.Entity)
override this.GetRelatedEntity : string * Nullable<Microsoft.Xrm.Sdk.EntityRole> -> 'Entity (requires 'Entity :> Microsoft.Xrm.Sdk.Entity)
Protected Overridable Function GetRelatedEntity(Of TEntity As Entity) (relationshipSchemaName As String, primaryEntityRole As Nullable(Of EntityRole)) As TEntity
Type Parameters
- TEntity
Type: Entity. The type of the entity.
Parameters
- primaryEntityRole
- Nullable<EntityRole>
Type: EntityRole. The role of the primary entity in the relationship (referenced or referencing).
Returns
- TEntity
Type: EntityThe collection of related entity instances for the specified relationship.
Examples
GetRelatedEntity<Account>("account_primary_contact", null);