好吧,NHibernate 可以解决任何问题。这可能是 Criteria 语法:
var list = session
.CreateCriteria<Customer>()
.SetProjection
(
Projections.SqlProjection
(
"fCompanyID, ROW_NUMBER() over( PARTITION BY fCompanyID order by fPropertyID) as RowNumber"
, new string[] {"fCompanyID", "RowNumber"}
, new IType[] { NHibernate.NHibernateUtil.Int32, NHibernate.NHibernateUtil.Int32}
)
)
.SetResultTransformer(Transformers.AliasToBean<ResultDTO>())
.List<ResultDTO>()
;
像这样ResultDTO
:
public class ResultDTO
{
public virtual int RowNumber { get; set; }
public virtual int fCompanyID{ get; set; }
}
现在您可以使用 alist
作为一组ResultDTO