Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

How to combine two entity-reference-collections

Posted on by 645

Hey I have two entity-reference-collections and I need to combine/merge/unite them into one, How can I do that?

*This post is locked for comments

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: How to combine two entity-reference-collections

    Hi ,

    Please provide your  specific requirement with scenario which will help to get clear answer from people here.

    I am assuming you want to merge entity collection in that case  there should be  some condition before merge, so you need to loop through one entity collection using .NET LINQ merge another entity reference based on conditions.

    If you want to simply add another same list of entity collection you can simply use -

    entCollection1.AddRange(listentCollection12);

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: How to combine two entity-reference-collections

    Hi Sahara,

    Like Guido asked, what exactly is your requirement.

    Adding to collection can be easily done using AddRange of a collection in .net code:

    List<EntityReference> list1 = new List<EntityReference>();

    List<EntityReference> list2 = new List<EntityReference>();

    Option 1:

    list2.AddRange(list1);

    Option 2:

    EntityReferenceCollection entityReferenceCollection = new EntityReferenceCollection(list1);

    entityReferenceCollection.AddRange(list2);

    You can play around with this as there are a lot of other options...

    Hope this helps.

  • Guido Preite Profile Picture
    Guido Preite 54,081 Super User 2024 Season 1 on at
    RE: How to combine two entity-reference-collections

    which is your exact requirement?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans