在流畅的nhibernate中,我可以设置一个实现类似接口的具体类的引用:
class Address : IAddress {
...
}
class Person {
public virtual IAddress Address {get;set;}
}
...
class PersonMap : ClassMap<Person> {
public PersonMap() {
References<Address>(x => x.Address).Column("AddressId");
...
}
}
无论如何使用只有nhibernate的代码映射来执行此操作吗?
谢谢!
答案 0 :(得分:2)
你的意思是通过喋喋不休的映射,对吗?就是这样做的:
using NHibernate;
using NHibernate.Mapping.ByCode;
using NHibernate.Mapping.ByCode.Conformist;
public class PersonMapping : ClassMapping<Person>
{
public PersonMapping()
{
...
ManyToOne(x => x.Address, map =>
{
map.Column("AddressId");
map.Class(typeof(Address));
}
);
...
}
}