Hi Otis, thanks, that's correct.
I fix this with a workaround, not sure is best practice but it works.
Updated the code to: (note the commented code)
public IEntityCollection2 GetEntityCollectionByEntityName(string entityName)
{
var myEntity = CreateEntity(entityName);
var entityFactory = myEntity.GetEntityFactory();
//var collectionToFill = entityFactory.CreateEntityCollection(); //Returns EntityCollection<T>. Doesn't work!
var collectionToFill = new EntityCollection(entityFactory); // Returns EntityCollection<EntityBase2>
using (var adapter = new DataAccessAdapter())
{
adapter.FetchEntityCollection(collectionToFill, null, 1000);
}
return collectionToFill;
}
Then on WCF I only need to add
[ServiceContract]
[ServiceKnownType(typeof(EntityCollection))]
where CreateEntity is
private IEntity2 CreateEntity(string entityName)
{
return GeneralEntityFactory.Create((EntityType) Enum.Parse(typeof(EntityType), entityName));
}