However, my eyes hurt when reading criteria :) Tuna Toksöz Eternal sunshine of the open source mind.
http://devlicio.us/blogs/tuna_toksoz http://tunatoksoz.com http://twitter.com/tehlike On Tue, Apr 28, 2009 at 1:23 PM, Filip Kinsky <[email protected]> wrote: > > You're right - this really works. Thanks a lot. The final working > code: > > ISQLFunction sqlAdd = new VarArgsSQLFunction("(", "+", ")"); > ISQLFunction sqlDivide = new VarArgsSQLFunction("(", "/", ")"); > ISQLFunction sqlMultiply = new VarArgsSQLFunction("(", "*", ")"); > ISQLFunction sqlSubstract = new VarArgsSQLFunction("(", "-", ")"); > > var ym = Year.Value * 100 + Month.Value; > var dateFromMonthProj = Projections.SqlFunction("month", > NHibernateUtil.Int32, Projections.Property("Duration.DateFrom")); > var dateFromYearProj = Projections.SqlFunction("year", > NHibernateUtil.Int32, Projections.Property("Duration.DateFrom")); > var dateToMonthProj = Projections.SqlFunction("month", > NHibernateUtil.Int32, Projections.Property("Duration.DateTo")); > var dateToYearProj = Projections.SqlFunction("year", > NHibernateUtil.Int32, Projections.Property("Duration.DateTo")); > var calculatedYMFrom = Projections.SqlFunction(sqlAdd, > NHibernateUtil.Int32, Projections.SqlFunction(sqlMultiply, > NHibernateUtil.Int32, dateFromYearProj, Projections.Constant(100)), > dateFromMonthProj); > var calculatedYMTo = Projections.SqlFunction(sqlAdd, > NHibernateUtil.Int32, Projections.SqlFunction(sqlMultiply, > NHibernateUtil.Int32, dateToYearProj, Projections.Constant(100)), > dateToMonthProj); > q.Add(Restrictions.Le(calculatedYMFrom, ym)); > q.Add(Restrictions.Ge(calculatedYMTo, ym)); > > On 28 Dub, 11:48, Tuna Toksoz <[email protected]> wrote: > > For mathematics, I believe you can use > > > > var arithmaticAddition = new VarArgsSQLFunction("(", "+", ")"); > > var arithmeticDivide = new VarArgsSQLFunction("(", "/", ")"); > > var arithmaticMultiply = new VarArgsSQLFunction("(", "*", ")"); > > var arithmaticSubstract = new VarArgsSQLFunction("(", "-", ")"); > > > > Does that make sense? > > > > Tuna Toksöz > > Eternal sunshine of the open source mind. > > > > > http://devlicio.us/blogs/tuna_toksozhttp://tunatoksoz.comhttp://twitter.com/tehlike > > > > On Tue, Apr 28, 2009 at 12:40 PM, Filip Kinsky <[email protected]> wrote: > > > calculatedYMFrom > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
