NHibernate에 대한 연구를 시작했는데 해결할 수없는 문제가 있습니다. 누군가 나를 도울 수 있는지 궁금합니다.NHibernate GroupBy and 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
NHaucnate를 즐기십시오. –