***THIS*** is what I've been looking for

The following code is what I’ve been looking for, and since discovering it, my problems with trying to match up routes to my domain logic has vanished. I can now select my aggregate root based on any of it’s downline, or their properties.

using NHibernate;
using NHibernate.Criterion;
namespace Genesis.Persistence
    using Genesis.Domain;
    using Genesis.Domain.Persistence;
    using Genesis.Infrastructure.Persistence;
    public class CategoryRepository : Repository<Category>, ICategoryRepository
        public Category SelectByForumId(int forumId)
            ICriteria criteria = Session.CreateCriteria<Category>();
            // this line right here...nested criteria!!!
            criteria.CreateCriteria("Forums").Add(Expression.Eq("Id", forumId));
            return criteria.UniqueResult<Category>();

I wish I had been able to figure this out, or been able to explain better what it was I needed, a lot sooner. My problems with routing, using aggregate root only repositories, and my erroneous need for back references have all gone away.


Signed, Happy Camper.