相当于linq-to-nhibernate中的hql coalesce

时间:2011-03-18 15:56:46

标签: linq-to-nhibernate coalesce

假设我有以下hql:

select cast(coalesce(sum(c.Valoare), 0) as decimal)
      from Comision as c
      where c.User = :user

有没有办法在Linq-To-Nhibernate中写这个?

1 个答案:

答案 0 :(得分:0)

您可以使用C#null合并运算符吗?

(from c in Comision
where c.User = user
select c.Valoare ?? 0).Sum()