I have a generic object type Entity and some classes that can relate to Entity such as EntityDescription and EntityLocation (many-to-one relationships).
Entity class:
public class Entity
{
public virtual Int64 ID { get; set; }
// and other properties
}
EntityDescription class:
public class EntityDescription
{
public virtual Int64 ID { get; set; }
public virtual Entity Entity { get; set; }
public virtual String Description { get; set; }
// and other properties
}
EntityLocation class:
public class EntityLocation
{
public virtual Int64 ID { get; set; }
public virtual Entity Entity { get; set; }
public virtual String Location { get; set; }
// and other properties
}
There are a number of more specific entity types e.g. Company, Supplier, Employee, etc. To make things more interesting, EntityDescription applies to all specific types, but only some types can be assigned locations (EntityLocation is only applicable to some types).
How do I map these classes in Fluent-NHibernate so that EntityLocation list is only exposed on some specific classes that can have locations (e.g. Company and Supplier), and not on the generic Entity class?
// This property can exist in Entity
public virtual IList<EntityDescription> Descriptions { get; set; }
// I want this property to only exist in some specific types, not in Entity
public virtual IList<EntityLocation > Locations { get; set; }
Any help appreciated. Thanks in advance.