私にとって、私はグループ化しようとしている要素から始めます。だから、 キャンペーンのベースから始めましょう。あなたの質問から私は分かりませんが、あなたのマッピングにはキャンペーンから販売リードへの移行方法があると思います。私はこれが "SALES_LEAD_LIST"と呼ばれると仮定しました。
また、投影結果を受け取る小さなクラスを作って、結果を保持するものを作成するのが好きです。あなたはあなたの中にあなたの投影結果を置くために何かを持っていたら
public class CAMPAIGN_PERFORMANCE
{
public CAMPAIGN_PERFORMANCE() {}
public int CP_ID {get; set;}
public string CP_NAME {get; set;}
public int CP_NO_OF_SALES_LEADS {get; set;}
}
は、標準的な基準を作成し、ちょうど投影を紹介する新しいクラスにそれをプッシュすることができます
ICriteria criteria = base.Session.CreateCriteria(typeof(SA_CAMPAIGNS));
criteria.CreateAlias("SALES_LEADS_LIST", "SA_LEADS", JoinType.InnerJoin);
criteria.SetProjection(Projections.ProjectionList()
.Add(Projections.Property("ID"), "CP_ID")
.Add(Projections.Property("CAMPAIGN_NAME"), "CP_NAME")
.Add(Projections.CountDistinct("SA_LEADS.ID"), "CP_NO_OF_SALES_LEADS")
.Add(Projections.GroupProperty("ID"));
.Add(Projections.GroupProperty("CAMPAIGN_NAME")));
IList<CAMPAIGN_PERFORMANCE> cpProjections = criteria
.SetResultTransformer(
new AliasToBeanResultTransformer(typeof(CAMPAIGN_PERFORMANCE)))
.List<CAMPAIGN_PERFORMANCE>();