문제

I have requirement, wherein I have to calculate totals for cash and credit cards separately using conditional projection queries. My below code doesnt work and it gives me datatype mismatch error. Its says the true condition returns decimal and false returns currency. I am not sure why it does that as 0.0M does represent decimal. Can anybody please help me out with the query?

RefundTemplate.Criteria.SetProjection(
                        Projections.ProjectionList()

                        .Add(Projections.Sum(Projections.Conditional
                            (Restrictions.Eq("PaymentType", "CK"),
                                  Projections.Property("Gross"), Projections.Constant(0.0M))), "CashRefund")
                        .Add(Projections.Sum(Projections.Conditional
                            (Restrictions.Eq("PaymentType", "CC"),
                                  Projections.Property("Gross"), Projections.Constant(0.0M))), "CreditRefund"));
도움이 되었습니까?

해결책

You can specify explicitly which type to use. For example:

Projections.Constant(0.0M, NHibernateUtil.Decimal)

See the documentation for the NHibernateUtil class here: http://elliottjorgensen.com/nhibernate-api-ref/NHibernate/NHibernateUtil.html

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top