Ignore Base class with Sharp Architecture and Fluent NHibernate
-
19-01-2021 - |
Frage
Using Sharp Architecture 1.9
I have a base class that inherits from the Sharp Arch Entity class
public class LineItem : EntityWithTypedId<Guid>
{
// various properties
}
and then two classes that inherit:
public class BasketItem : LineItem { public virtual Basket Basket; ...}
public class OrderItem : LineItem { public virtual Order Order ...}
In my database I have two tables. BasketItems and OrderItems.
My problem: Fluent NHibernate (AutoMapping) is trying to map LineItem.
My question: How do I tell NHibernate to ignore the LineItem mapping given that I still want to map the EntityWithTypedId property to the BasketItems and OrderItems table?
Lösung 2
The solution was to add code like this to my automap configuration:
AutoMap.AssemblyOf<Entity>(cfg)
.IgnoreBase<Entity>();
More info here.
Andere Tipps
it depends on what the table structure of the basketitem and orderitem are. Are you using the table per concrete class or table per class hierarchy?
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow