tags:

views:

48

answers:

1

I'm currently getting a list of Groups as follows:

var groups = _session.CreateCriteria<CompanyGroupInfo>()
    //.SetProjection(Projections.ProjectionList()
    //    .Add(LambdaProjection.Count<Company>(c => c.Id) > 0))
    .AddNameSearchCriteria<CompanyGroupInfo>(searchExpression)
    .AddOrder<CompanyGroupInfo>(e => e.Name, Order.Asc)
    .SetMaxResults(pageSize).List<CompanyGroupInfo>();

What I'm trying to return is groups, which contains multiple companies

I need to filter this list so that I don't return any group that doesn't contain any companies. I was hoping I could do something similar to what's commented out, but that doesn't work. I'm pretty new to NHibernate, so this is probably a really simple issue. Unfortunately, I don't know what to do! Could somebody please point me in the right direction?

A: 

Have you tried something like:

.Add(Restrictions.IsNotEmpty("Companies"))

The converse of this.

David