【发布时间】:2013-01-12 17:53:50
【问题描述】:
真正大师的简单问题。
我浪费了很多时间来弄清楚如何在 nhib 中映射集合。通过代码映射,我现在有疑问,为什么我的映射适用于 IList 类型的集合而不是 List?
这是代码
public class Account {
private IList<Term> Terms; // When I use List it does not work
public Account()
{
Terms = new List<Terms>();
}
public virtual IList<Term> Terms // When I use List it does not work
{
get { return _Terms; }
set
{ if (_Terms == value) return;
_Terms = value;
}
}
}
AccountMap.cs(一个账户有多个条款)
Bag(x => x.Terms,
m =>{},
x => x.OneToMany()
);
【问题讨论】:
-
怎么不行?我认为 NHibernate 要求您为要延迟加载的映射集合使用接口类型,因为它需要在运行时代理它们。
标签: c# nhibernate