3

I have the entity defined below:

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; }
    }

    // ...
}

And here's the base class:

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

    // ...
}

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();

The error I get is: NHibernate.QueryException : could not resolve property: Id of: Foo

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

4

1 回答 1

1

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

于 2013-02-08T16:37:28.787 回答