Search code examples
c#.netdynamics-crm

new instance / constructor of Microsoft.Xrm.Sdk.DataCollection<T>


How to create a new instance of Microsoft.Xrm.Sdk.DataCollection<T> class? I've done it by following code, but it doesn't seem all right to me:

DataCollection<Entity> dc = (new EntityCollection()).Entities;

Solution

  • The Microsoft.Xrm.Sdk.DataCollection<T> class does not have a public constructor, so you cannot use it the way you are showing.

    As an alternative you can design a collection class of your own and implement the ICollection<T> interface or any other interface you need.