This is partly related to this.
I'd like to find a way to sort of a linked (HasMany) collection result directly in the Nhibernate query.
ICriteria criteria = Session.CreateCriteria(typeof(PortalPage));
criteria.CreateAlias("PartialViews", "vc");
criteria.AddOrder(Order.Asc("vc.ColumnNumber"));
criteria.Add(Property.ForName("Url").Eq(pageUrl));
return criteria.UniqueResult<PortalPage>();
Correcly generates a select with the ORDER BY but the result in the linked collection is not ordered.
I'd like to avoid sorting the collection after the result is returned (like using linq to objects) is this possible?
UPDATE: As Steve suggested the problem can be solved by hard coding the order attribute in the mapping like:
HasMany(x => x.PartialViews).KeyColumnNames.Add("PageId").AsBag().SetAttribute("order-by", "ColumnNumber");