I'm trying to create a collection with Generics.
where E : MarketEntity
public class GenericMapper<E, B>
where E : CommonEntityBase
where B : IBusinessObject
{
public static EntityCollectionBase<E> ToCollection(List<B> oldBusinessObjecList)
{
if (oldBusinessObjecList == null) return null;
//This line give me an error
EntityCollectionBase<E> newCollecion = new EntityCollectionBase<E>();
foreach (B businessObject in oldBusinessObjecList)
{
Mapper.CreateMap<B, E>();
newCollecion.Add(Mapper.Map<B, E>(businessObject));
}
return newCollecion;
}
}
EntityCollectionBase<E> newCollecion = new EntityCollectionBase<E>();
This gives me a compile error but seems to work when I pass EntityCollectionBase<E> into a function.
Any Suggestions?