Hi guys,
I'm having a bit of trouble writing a class that uses generics because this is the first time that I have had to create a class that uses generics.
All I am trying to do is create a method that converts a List to an EntityCollection.
I am getting the compiler error: The type 'T' must be a reference type in order to use it as parameter 'TEntity' in the generic type or method 'System.Data.Objects.DataClasses.EntityCollection'
Here is the code that I am trying to use:
public static EntityCollection<T> Convert(List<T> listToConvert)
{
EntityCollection<T> collection = new EntityCollection<T>();
// Want to loop through list and add items to entity
// collection here.
return collection;
}
It is complaining about the the EntityCollection collection = new EntityCollection() line of code.
If anyone could help me out with this error, or explain to me why I am receiving it I would greatly appreciate it. Thanks.