I tried the following query to return row count of query result and it returned incorrect value.
Can anybody tell me how to return the row count of SetResultTransformer result? Thank you very much. By the way, I'm using NHibernate 1.2 RC2.
Code:
return Session().CreateCriteria(typeof(Order))
.CreateAlias("OrderItems", "OrderItem")
.CreateAlias("OrderItem.Product", "Product")
.SetProjection(Projections.ProjectionList()
.Add(Projections.GroupProperty("Product.Id").As("Id"))
.Add(Projections.GroupProperty("Product.ProductName").As("ProductName"))
.Add(Projections.Sum("OrderItem.Quantity").As("TotalOrdered")))
.SetResultTransformer(Transformers.AliasToBean(typeof (TopProductDTO)))
.SetProjection(Projections.RowCount()).UniqueResult()