OrganizationServiceContextExtensions.AddRelatedObject<TSource, TTarget> Method (OrganizationServiceContext, TSource, Expression<Func<TSource, IEnumerable<TTarget>>>, TTarget)


Applies To: Dynamics CRM 2015

Namespace:   Microsoft.Xrm.Client
Assembly:  Microsoft.Xrm.Client (in Microsoft.Xrm.Client.dll)


public static void AddRelatedObject<TSource, TTarget>(
    this OrganizationServiceContext context,
    TSource source,
    Expression<Func<TSource, IEnumerable<TTarget>>> propertySelector,
    TTarget target
where TSource : Entity
where TTarget : Entity
generic<typename TSource, typename TTarget>
where TSource : Entity
where TTarget : Entity
static void AddRelatedObject(
    OrganizationServiceContext^ context,
    TSource source,
    Expression<Func<TSource, IEnumerable<TTarget>^>^>^ propertySelector,
    TTarget target
static member AddRelatedObject<'TSource, 'TTarget when 'TSource : Entity when 'TTarget : Entity> : 
        context:OrganizationServiceContext *
        source:'TSource *
        propertySelector:Expression<Func<'TSource, IEnumerable<'TTarget>>> *
        target:'TTarget -> unit
Public Shared Sub AddRelatedObject(Of TSource As Entity, TTarget As Entity) (
    context As OrganizationServiceContext,
    source As TSource,
    propertySelector As Expression(Of Func(Of TSource, IEnumerable(Of TTarget))),
    target As TTarget


  • source
    Type: TSource

    Type: TSource. The source entity instance.

  • target
    Type: TTarget

    Type: TTarget. The target entity instance.

Type Parameters

  • TSource
    The source entity.
  • TTarget
    The target entity.


This is an extension to the core AddRelatedObject method.

See Also

AddRelatedObject Overload
OrganizationServiceContextExtensions Class
Microsoft.Xrm.Client Namespace

Return to top

© 2017 Microsoft. All rights reserved. Copyright