I am attempting to write a question that can take a qualifying criterion and returns a count projection, this is exactly what i am using right now but it is really inefficient, why applying for grants the way i can replace this?

    /// <summary> Each criteria contributes one row </summary>
    private IProjection AsCount( ICriterion criterion )
        if (criterion == null) {
            return Projections.RowCount();
        } else {
            return Projections.Sum( Projections.Conditional( criterion,
                Projections.Cast( NHibernateUtil.Int32, Projections.Constant( 1 ) ),
                Projections.Cast( NHibernateUtil.Int32, Projections.Constant( 0 ) ) ) );

So guess what happens i am actualy attempting to do here, I've got a number of criteria expressions and I have to produce a arranged table in which the posts would be the expressions.

I did not look for a better solution than this however i don't belive this is an inefficient when i first thought.