It's right. It can actually be a problem.
Thank you Em quinta-feira, 7 de maio de 2015 14:09:32 UTC-3, Gunnar Liljas escreveu: > > OK, I never use QueryOver, so there may be issues (report to JIRA if you > feel it's a bug). > > In Linq I would do something like > > .Sum(x=>(decimal?)x.Valor).GetValueOrDefault(0)==0 > > 2015-05-07 18:10 GMT+02:00 glautter neves <[email protected] <javascript:> > >: > >> Gunnar, very good, >> >> but also does not generate "HAVING". Generated "And". >> >> *AND *nvl(sum(classAlias.value), 0) = 0 >> >> If I put just the condition of zero, it generates "*HAVING*". >> Where(Restrictions.Eq(Projections.Sum<MyClass>((x) => x.Valor), 0)) >> >> thank you very much >> >> Em quinta-feira, 7 de maio de 2015 12:34:25 UTC-3, Gunnar Liljas escreveu: >>> >>> Sum returns null if there is nothing to aggregate. >>> >>> Maybe this will work: >>> >>> .Where(Restrictions.Eq(Projections.SqlFunction("coalesce", >>> NHibernateUtil.Object,Projections.Sum<MinhaClasse>(x => x.Valor), >>> Projections.Constant(0)), 0)); >>> >>> In other words >>> >>> having coalesce(sum(value),0)=0 >>> >>> 2015-05-07 15:03 GMT+02:00 glautter neves <[email protected]>: >>> >>>> Hi, >>>> >>>> I have made the sql out and is working, but I need to generate the >>>> queryover. >>>> >>>> There are several relationships. This return is for a subquery and the >>>> sum is for a list that has not always record but may also exist records >>>> with zero values. >>>> >>>> Thank you, >>>> >>>> I have solved this case in bold, but is ignoring the "Having" and >>>> generating "And" >>>> Having *(sum (value) == 0) OR (sum (value) IS NULL);* >>>> >>>> using: >>>> .Where(Restrictions.Eq(Projections.Sum<MinhaClasse>((x) => x.Valor), 0) >>>> || Restrictions.IsNull(Projections.Sum<MinhaClasse>((x) => x.Receita))) >>>> >>>> maybe use a coalesce >>>> >>>> Em quinta-feira, 7 de maio de 2015 09:42:05 UTC-3, sql-expert escreveu: >>>>> >>>>> Hi: >>>>> >>>>> *OR* (sum(valor) IS NULL >>>>> Why are you testing the result of an aggregate function, especially >>>>> SUM for NULL? In SQL, aggregate functions like sum() normally ignore >>>>> NULLs. >>>>> sum(x) should normally never return NULL. If you do get NULLs at the C# >>>>> level, there are several ways to handle that. >>>>> >>>>> HTH. >>>>> >>>>> On Thu, May 7, 2015 at 6:29 AM, Michael Powell <[email protected]> >>>>> wrote: >>>>> >>>>>> English please. Thank you. >>>>>> >>>>>> -- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "nhusers" group. >>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>> send an email to [email protected]. >>>>>> To post to this group, send email to [email protected]. >>>>>> Visit this group at http://groups.google.com/group/nhusers. >>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>> >>>>> >>>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "nhusers" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> To post to this group, send email to [email protected]. >>>> Visit this group at http://groups.google.com/group/nhusers. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "nhusers" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> Visit this group at http://groups.google.com/group/nhusers. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/nhusers. For more options, visit https://groups.google.com/d/optout.
