This question is locked. New answers and comments are not allowed.
I have a Data Access project that consists of entities derived from a base class, defined like this:
..using the horizontal inheritance strategy in Data Access, mapped like this:
I did this in an attempt to consolidate a large number of entity methods (CRUD, basically) into the base class, as they were very similar, only differing in what entity they worked on or returned.
This builds okay but fails at runtime when attempting to update the database. The call to ISchemaHandler.CreateUpdateDDLScript throws an exception :
I'm no expert on inheritance or generics in C#, so I can't parse this. I did notice this in the stack trace, though:
Is my attempt at generic'izing the CRUD methods of my data layer tripping up Data Access' mapping? Is what I'm trying impossible or how do I proceed?
TIA
public abstract class EntityBase<T> where T : EntityBase<T> { }public class Entity: EntityBase<Entity> { }..using the horizontal inheritance strategy in Data Access, mapped like this:
var entityBaseMapping = new MappingConfiguration<EntityBase<Entity>>();entityBaseMapping.MapType().Inheritance(InheritanceStrategy.Horizontal);mappingConfigurations.Add(entityBaseMapping);var entityMapping = new MappingConfiguration<Entity>();entityMapping.MapType().ToTable("entity");entityMapping.HasProperty(x => x.Id).IsIdentity();mappingConfigurations.Add(entityMapping);I did this in an attempt to consolidate a large number of entity methods (CRUD, basically) into the base class, as they were very similar, only differing in what entity they worked on or returned.
This builds okay but fails at runtime when attempting to update the database. The call to ISchemaHandler.CreateUpdateDDLScript throws an exception :
[InvalidOperationException: Could not execute the method because either the method itself or the containing type is not fully instantiated.]I'm no expert on inheritance or generics in C#, so I can't parse this. I did notice this in the stack trace, though:
[MetadataException: Mapping for class 'Namespace.Entity' is specified in file 'config' but the class could not be found. --> Context/namespace[Namespace]/class[Entity]]Is my attempt at generic'izing the CRUD methods of my data layer tripping up Data Access' mapping? Is what I'm trying impossible or how do I proceed?
TIA