This code throws exception "subcriteria cannot be ordered". Foo and Bar are related through the mapping file. I am trying to order the results by a column in the Bar table but I am selecting Foos based on the Foo ID.
Code:
ICriteria crit = session.CreateCriteria(typeof(Foo));
crit.Add(NHibernate.Expression.Expression.Eq("FooId", 1);
crit.CreateCriteria("Bar").AddOrder(NHibernate.Expression.Order.Asc("BarName"));
IList tprList = crit.List();
How can I order by a column in a related table to the one I am basing my criteria on?
Thanks