NHibernate:无法解析继承的id属性 [英] NHibernate: cannot resolve inherited id property

查看:89
本文介绍了NHibernate:无法解析继承的id属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的实体定义如下:

public class Foo : Entity<Foo.FooId>
{
    public class FooId
    {
        public virtual String Bar { get; protected internal set; }
        public virtual Int32 Buzz { get; protected internal set; }
    }

    // ...
}

这是基类:

public abstract class Entity<T> : IEquatable<Entity<T>>
{
    public virtual T Id { get; protected internal set; }

    // ...
}

我将"Id"属性映射为复合键",因此我添加了以下映射类:

I'm going to map the "Id" property as a "composite key", so I've added the following mapping class:

public class FooMap : ClassMapping<Foo>
{
    public FooMap()
    {
        ComponentAsId(x => x.Id, m =>
        {
            m.Property(p => p.Bar);
            m.Property(p => p.Buzz);
        });
    }
}

这一切都很好,但是以下查询尝试出现错误:

And that's all pretty nice, but I get an error with the following querying attempt:

session.QueryOver<Foo>()
       .Where(m => m.Id.Bar == "a" &&
                   m.Id.Buzz == 2).List();

我得到的错误是: NHibernate.QueryException:无法解析属性:Id of:Foo

这很奇怪,因为通过删除基类并将所有内容封装在"Foo"中,它就像一个魅力. 预先感谢.

It's quite strange, because by removing the base class and encapsulating everything within "Foo", it works like a charm. Thanks in advance.

推荐答案

这是一个错误,报告为 NH-3105 .现在,它已在最新的源代码中修复,并将以3.3.3版本发布. GA.

This was a bug and reported as NH-3105. It is now fixed in the most recent of the source code and will be released as 3.3.3.GA.

这篇关于NHibernate:无法解析继承的id属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆