Otis wrote:
I didn't get that from the posts you made in this thread.
Anyway, the thing is that you should pass in the factory for the supertype, that one is used to obtain fields for the query, and then based on the row data, the proper factory is produced and is used to create the subtype instance.
I think in this mechanism is the reason why you don't see your factory used: in the InheritanceInfoProvider.cs class (generated in the helper classes folder/namespace), the factory per type is specified. It's this factory that's returned to the o/r core to use for the type, not yours.
You can intercept this in your supertype's factory, by overriding 'GetEntityFactory' and first call the base' method. If it returns the type you want to override, return an instance of the factory you want to use instead.
Thanks that was the information I was missing, I still use the subtype factory but I changed the GetEntityFactory method for EntityFactoryBase2 from
public override IEntityFactory2 GetEntityFactory(object[] fieldValues, Dictionary<string, int> entityFieldStartIndexesPerEntity)
{
IEntityFactory2 toReturn = (IEntityFactory2)InheritanceInfoProviderSingleton.GetInstance().GetEntityFactory(this.ForEntityName, fieldValues, entityFieldStartIndexesPerEntity);
if(toReturn == null)
{
toReturn = this;
}
return toReturn;
}
to
public override IEntityFactory2 GetEntityFactory(object[] fieldValues, Dictionary<string, int> entityFieldStartIndexesPerEntity)
{
IEntityFactory2 toReturn = (IEntityFactory2)InheritanceInfoProviderSingleton.GetInstance().GetEntityFactory(this.ForEntityName, fieldValues, entityFieldStartIndexesPerEntity);
if(toReturn == null || this.GetType() == toReturn.GetType())
{
toReturn = this;
}
return toReturn;
}
Hope I didn't break anything, but even if I did I'll handle it when I get there, thanks for the help!