我试图这样做:
Key key = session.QueryOver<Key>()
.Left.JoinQueryOver<ConfigValue>(x => x.ConfigValues)
.Where(c => c.Id == cfgValue.Id)
.SingleOrDefault();
但我有这个例外:
NHibernate.QueryException was unhandled by user code
Message=could not resolve property: ConfigValues of: Domain.Model.Key
页: 1 关键代码>物体的申报方式是限制使用IList的出入,并用无形财产绘制。
public class Key
{
public virtual int Id { get; protected set; }
public virtual IEnumerable<ConfigValue> ConfigValues { get { return _configValues; } }
private IList<ConfigValue> _configValues = new List<ConfigValue>();
...
法典化如下:
Bag<ConfigValue>("_configValues", attr => {
attr.Lazy(CollectionLazy.Lazy);
attr.Inverse(false);
attr.Cascade(Cascade.None);
}, cm => cm.ManyToMany());
www.un.org/Depts/DGACM/index_spanish.htm 问题: 我如何使用NHibernate AP?
我设法做到的唯一办法是:
IList<Key> keys = session.CreateQuery(@"select K_
from Key as K_
left outer join K_._configValues as KO_
where KO_.Id = :cfgValueId ")
.SetParameter("cfgValueId", cfgValue.Id)
.List<Key>();