I'm dealing with a legacy database that has a locked schema. The problem I'm facing is that a number of the tables are keyed off known/fixed/hard-coded entity type Id values instead of having a column values. This means that I can't use the normal References construct.
For the tables with the ENTITY_TYPEID I can do this:
public class EntityMap : ClassMap<Entity>
{
public EntityMap()
{
References(x => x.Type)
.Columns("ENTITY_SECTION","ENTITY_TYPEID");
}
}
which happily populates the Entity.Type.
For the tables of a fixed/known/hard-coded type I need to map to a hard-coded value instead of the ENTITY_TYPE column, so to para-phrase in code:
public class EntityXMap : ClassMap<EntityX>
{
public EntityXMap(int entityType)
{
References(x => x.Type)
.Columns("ENTITY_SECTION", "ENTITY_TYPE = 123" );
}
}
HasMany() has a Where() construct that I could use in that case...
Any ideas how to achieve something similar here?