Nhibernate Mapping interface
How to map an interface using fluent Nhibernate
class Product {
public virtual IProductStructure ProductStructure { get; set; }
}
public class ProductMap : SubclassMap<Product>
{
public ProductMap()
{
HasOne(x => x.IProductStructure).PropertyRef(x => x.Product).Cascade.All();
}
}
public interface IProductStructure
{
Product Product { get; set; }
}
error : N开发者_StackOverflowHibernate.MappingException : property-ref to unmapped class: .....Test.IStructure thanks .
Your mapping needs to be to a concrete class. In your case to the implementation of IProductStructure
.
精彩评论