How do you map an entity -> interface relationship using Fluent NHibernate?

后端 未结 4 1151
太阳男子
太阳男子 2021-01-05 07:38

given the following class definition:

public class Order {
  public IProduct Product {get;set;}
}

I have this (fluent) mapping



        
4条回答
  •  北荒
    北荒 (楼主)
    2021-01-05 08:22

    You could map the interface->implementation relationship as an inheritance relationship, using an appropriate inheritance model.

    That would mean mapping IProduct and then creating a subclass map of Product in the IProduct mapping, for example using table-per-hierarchy.

    That would also let you map additional data in the product class that is not part of the IProduct interface, and also let you map additional IProduct implementations in the same way if you wish to.

提交回复
热议问题