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

后端 未结 4 1137
太阳男子
太阳男子 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

    I think what you're looking for is .References(x=>x.Product, "ProductId");

    Incidentally the same is true for .HasMany<>

    This seems to do the same as <... class="Product" /> in xml

    I wouldn't recommend mapping to the interface as it breaks the whole point of using one - you run into problems as soon as it starts implementing IStorable and NH can't cope with the multiple inheritance.

提交回复
热议问题