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; }
// ... equality members are accurately overridden...
}
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.
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/nhusers/-/heywEA3N2P0J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.