I have entity Recipes and it has a HasMany collection comments.
In a MVC controller action I am getting the recipe
and then displaying the comments.
How do I sort the comments in descending order of “EnteredOn”?
Where do I sort them?
Recipe recipe = session.Load<Recipe>(id);
NHibernateUtil.Initialize(recipe.Comments);
Malcolm
I think I would just retrieve the comments as-is (not particulary sorted), and then just sort the Comments collection of the recipe, before you display the comments.
Depending on how you’ve created your class, and your mapping, I think this is the only way since a set and bag mapping, represent un-ordered collections in NHibernate.
Something like this:
Where my Reciple entity looks something like this:
and the mapping: