私はNHibernateに関する研究を開始しています。私は解決できない問題があります。誰かが私を助けることができるのだろうかと思います。NHibernate GroupByとSum
マッピングが「正しく」取り組んでいるが、私はグループ化して合計を実行しようとする場合、アプリケーションは次のエラーを返します。
"could not resolve property: Course.Price of: Persistence.POCO.RequestDetail"
var criteria = session.CreateCriteria(typeof(RequestDetail))
.SetProjection(
Projections.ProjectionList()
.Add(Projections.RowCount(), "RowCount")
.Add(Projections.Sum("Course.Price"), "Price")
.Add(Projections.GroupProperty("Request"), "RequestId")
)
.AddOrder(Order.Asc("RequestId"))
.SetResultTransformer(Transformers.AliasToEntityMap)
.List();
注1:私は、コード.Add(Projections.Sum ("Course.Price"), "Price")
を取るアプリケーション結果を正しく返します。
注2:
query.Length = 0;
query.AppendLine("select");
query.AppendLine(" s.Id,");
query.AppendLine(" s.Identification,");
query.AppendLine(" sum(c.Price) as Total");
query.AppendLine("from");
query.AppendLine(" Student s");
query.AppendLine("inner join");
query.AppendLine(" Request r on r.StudentId = s.Id");
query.AppendLine("inner join ");
query.AppendLine(" Requestdetail rq on rq.RequestId = r.Id");
query.AppendLine("inner join");
query.AppendLine(" Course c on c.Id = rq.CourseId");
query.AppendLine("Group by");
query.AppendLine(" s.Id, s.Identification");
query.AppendLine("Order by");
query.AppendLine("s.Identification");
IQuery criteria = session.CreateSQLQuery(query.ToString())
.SetResultTransformer(Transformers.AliasToBean<Teste>());
IList<Teste> teste = criteria.List<Teste>();
は、誰もがこの問題を経験している:私は何ができる唯一の方法は、以下のコードを実行したのか?
感謝の男が...あなたのソリューションは、完全に見ることがとても素晴らしいことだ – Rick
を働いた既知のタイプのリストに結果を変換します –