Question

Is it possible to create a anoynmous count with nhibernate?

The below query throws the exception "No column *". I could of course add a column name, but I'd prefer not to, because if I do, I'll have to lookup column names for 95 tables...

NHibernate.Criterion.DetachedCriteria dcIsUniqueDomainname = NHibernate.Criterion.DetachedCriteria.For<nhDBapi.Tables.clsDomains>()
               .SetProjection(
                   NHibernate.Criterion.Projections.Count("*")
               )
               .Add(NHibernate.Criterion.Property.ForName("DomainID").Eq(strDomainID))
               .Add(NHibernate.Criterion.Property.ForName("DomainName").Eq(strDomainName)
           );
Was it helpful?

Solution

You are Looking for Projections.RowCount().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top