I am trying to order a collection that I am eagerly fetching but cannot seem to come up with the correct criteria call. I have speciefied that the collection should be ordered in the mapping but that seems to get discarded if I do an Eager fetch.
Here is the mapping
Code:
<bag name="SubSteps" table="Step" access="field.camelcase-underscore" lazy="true"
cascade="all-delete-orphan" inverse="true" order-by="Sequence asc">
Here is the current code that ignores the order by in the mapping:
Code:
ICriteria criteriaQuery = this.Session.CreateCriteria(typeof(RootStep));
criteriaQuery.Add(Expression.Eq("Procedure", this.Procedure));
criteriaQuery.AddOrder(Order.Asc("Sequence"));
criteriaQuery.SetFetchMode("SubSteps", FetchMode.Eager);
criteriaQuery.SetResultTransformer(CriteriaUtil.DistinctRootEntity);
I have an order by
sequence set for the root step list but I also need the substeps ordered.
I have tried to specify subcriteria and order the collection that way but I get an exception that states that subcriteria cannot be ordered.
I would appreciate any advice on this.
Thanks.