2
我有以下查詢,幫助與NHibernate標準查詢GROUPBY財產
SearchTemplate Template = new SearchTemplate();
Template.Criteria = DetachedCriteria.For(typeof(table1));
Template.Criteria.CreateCriteria("table2", "Usr", NHibernate.SqlCommand.JoinType.InnerJoin)
.SetProjection(Projections.ProjectionList()
.Add(Projections.Count("Usr.ID"), "UserCount")
.Add(Projections.GroupProperty("Location"), "ALocation")
.Add(Projections.GroupProperty("Company"), "ACompany")
.Add(Projections.GroupProperty("Usr.Designation"), "ADesignation"));
上述查詢給我數據,
Location Company Designation Count
Florida A Manager 3
Florida A QA 5
Texas B Manager 6
Texas B QA 7
有沒有辦法更改查詢,以便它給數據,
Location Company Manager QA
Florida A 3 5
Texas B 6 7
這裏經理,QA是可以進入指定領域的唯一可能的值..取而代之的
.Add(Projections.Count("Usr.ID"), "UserCount")
.Add(Projections.GroupProperty("Usr.Designation"), "ADesignation")
我低頭你的知識+1 – Vadim 2011-02-01 20:23:39