我有要求,其中我必须使用条件投影查询分别计算现金和信用卡的总数。我下面的代码不起作用,它给了我数据类型不匹配错误。它说真条件返回十进制,假返回货币。我不确定它为什么会这样,因为 0.0M 确实代表十进制。有人可以帮我查询吗?
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"));