// Code is generated using LLBLGen Pro version: 2.0.0.0
// Code is generated using templates: SD.TemplateBindings.SharedTemplates.NET20
// Database used is SQL Server 2005
// Template: adapter two classes
Ok. I have "Task" table with a one to many relationship to "TaskVersions".
In code I fetch a MyTaskEntity with a prefetch path for TaskVersions.
Then when I access TaskVersionCollection in MyTaskEntity I get a
EntityCollection<TaskVersionEntity> instead of
EntityCollection<MyTaskVersionEntity>.
/// <summary>
/// Gets the EntityCollection with the related entities of type 'MyTaskVersionEntity' which are related to this entity via a relation of type '1:n'.
/// If the EntityCollection hasn't been fetched yet, the collection returned will be empty.
/// </summary>
[TypeContainedAttribute(typeof(MyTaskVersionEntity))]
public override EntityCollection<TaskVersionEntity> TaskVersionCollection
{
get
{
EntityCollection<TaskVersionEntity> toReturn = base.TaskVersionCollection;
toReturn.EntityFactoryToUse = new MyTaskVersionEntityFactory();
return toReturn;
}
}
But I found the reason for this now so this thread is just in case some body else has a similar challenge.
My prefetch path was wrong:
I had:
PrefetchPath2 prefetch = new PrefetchPath2((int)EntityType.TaskEntity);
prefetch.Add(TaskEntity.PrefetchPathTaskVersionCollection);
which returns a collection of TaskVersionEntity for the TaskVersionCollection property
instead of:
PrefetchPath2 prefetch = new PrefetchPath2((int)EntityType.TaskEntity);
prefetch.Add(MyTaskEntity.PrefetchPathTaskVersionCollection);
which returns a collection of MyTaskVersionEntity for the TaskVersionCollection property
Hope it helps someone
Patrick