Understand differences between System.Collections.Generic.List.Add() & System.Collections.Generic.List.AddRange()

Hi,

For now we will jump back to our C# Collections to gain some understanding…

Firstly whenever we would like to add just one element to the collection we use List.Add as below

List<OrganizationRequest> RequestCollection = new List<OrganizationRequest>();

OrganizationRequest class is provided in Microsoft.Xrm.Sdk namespace.

For this list of organization request collection…if we want to add an element..we can do like this where CreateRequest  is part of OrganizationRequest

CreateRequest transCreate = new CreateRequest { Target = orderTransaction };
RequestCollection.Add(transCreate);//Adding a create request

Suppose if we want to add multiple elements…we can use as below..

RequestCollection.AddRange(orderStarValue,totalRewardStars,salesOrder,orderDate);

Hope this helps..

 


Discover more from ECELLORS CRM Blog

Subscribe to get the latest posts sent to your email.

Unknown's avatar

Author: Pavan Mani Deep Y

Passionate for Power Platform. A technology geek who loves sharing the leanings, quick tips and new features on Dynamics 365 & related tools, technologies. An Azure IOT and Quantum Computing enthusiast...

Leave a comment

Discover more from ECELLORS CRM Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading