English 中文(简体)
NHibernate Join Query 除无形财产外,还有例外。
原标题:NHibernate JoinQueryOver with a non-visible property throws exception
  • 时间:2011-11-22 19:27:40
  •  标签:
  • nhibernate

我试图这样做:

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>();
最佳回答

I m not firm with mapping by code but something along the lines

Bag<ConfigValue>("ConfigValues", attr => {
    attr.Access("field.camelcase-underscore");
}, cm => cm.ManyToMany());

或 液化NHibernate(如果有人有兴趣的话)

HasMany(x => x.ConfigValues)
    .Access.CamelCaseField(Prefix.Underscore);
问题回答

暂无回答




相关问题
nHibernate one-to-many inserts but doesnt update

Instead of getting into code, I have a simple question. Default behavior for a simple one-to-many is that it inserts the child record then updates the foreign key column with the parent key. Has ...

How Do I copy an existing nhibernate object as a new object?

I a persisted NHibernate object that I would like to repersist as a new entity. How do I get NHibernate to save this object as if it was a new? I am thinking I might create a session interceptor to ...

join across databases with nhibernate

I am trying to join two tables that reside in two different databases. Every time, I try to join I get the following error: An association from the table xxx refers to an unmapped class. If the ...

WPF - MVVM - NHibernate Validation

Im facing a bit of an issue when trying to validate a decimal property on domain object which is bound to a textbox on the view through the viewmodel. I am using NHibernate to decorate my property on ...

NHibernate Search in a List using ICriteria

I have my class X : public class ClassX { public virtual IList<ClassY> ListY { get; set; } ... } My ClassX mapping (using Fluent) ... HasMany<ClassX>(x => x.ListY ) ....

热门标签