AFAIK you have to ouse JoinQueryOver/JoinAlias to hoin Child with its parent and then use the joined parent to get the name.
Gustavo. On Tue, Dec 21, 2010 at 11:13 PM, vk37 <[email protected]> wrote: > When I execute the query: > > var r = session.QueryOver<Child>() > .OrderBy(x => x.Parent.Name) > .Asc > .ThenBy(x => x.Name) > .Asc > .List(); > > I receive the following exception: ‘could not resolve property: > Parent.Name of: Child’ > What I do wrong? > Below is the classes and the mapping. > > public class Parent > { > public int Id { get; set; } > public string Name { get; set; } > public IList<Child> Children { get; set; } > } > > public class Child > { > public int Id { get; set; } > public string Name { get; set; } > public Parent Parent { get; set; } > } > > <class name="Parent" lazy="false"> > <id name="Id" column="ParentId"> > <generator class="identity" /> > </id> > <property name="Name" /> > <bag name="Children" table="Child" inverse="true" > cascade="all"> > <key column="ParentId" /> > <one-to-many class="Child" /> > </bag> > </class> > > <class name="Child" lazy="false"> > <id name="Id" column="ChildId"> > <generator class="identity" /> > </id> > <many-to-one name="Parent" column="ParentId" not-null="true" /> > <property name="Name" /> > </class> > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<nhusers%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > -- You received this message because you are subscribed to the Google Groups "nhusers" group. 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.
