开发者

Ignore Base class with Sharp Architecture and Fluent NHibernate

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. Bask开发者_运维知识库etItems 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?


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?

Inheritance Mapping with Fluent NHibernate


The solution was to add code like this to my automap configuration:

AutoMap.AssemblyOf<Entity>(cfg)
  .IgnoreBase<Entity>();

More info here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜