views:

24

answers:

0

I have a very simple class:

    class Product  
    {  
       public virtual int ID { get;set;}  
       public virtual Categori MainCategori { get;set;}  
    }

i would like to make a "Select Count(ID),MainCategori From Products Group By MainCategori" by Using ICriteria. My code is like follows

        using (var sessionFactory = CMSData.GetSession())
        {

            var store = sessionFactory.CreateCriteria(typeof(DM.Domain.Entity.Portals.ProductPortal));              
            ProjectionList projList = Projections.ProjectionList(); 
            projList.Add(Projections.GroupProperty("MainCategori"));
            projList.Add(Projections.Count("ID"));
            store.CreateAlias("MainCategori", "mainCategori", NHibernate.SqlCommand.JoinType.None);
            IList<Object[]> count= store.SetProjection(projList).List<Object[]>();

        }

it works fine but i dont want the code to return a IList which contains a integer and a Categori. How does i get it to return a List with a int containing the count of product.

Regards Keld