Thanks for the advice. I was already thinking about it, but I'm trying to use query objects for these more complex queries (GUI filters) and I'm adding some other criterias in sequence in other classes so I'd need to redesign this first.
Germán Schuager wrote: > You can use named queries defined in your mappings; they don't get > strong type checking either, but they are verified at session factory > creation allowing you to catch any error soon enough. > > On Tue, Apr 28, 2009 at 7:37 AM, Filip Kinsky <[email protected] > <mailto:[email protected]>> wrote: > > > :)) > > I'd also prefer something else (namely in complex queries like this), > but HQL is bad because of no strong type support and afaik > Linq2NHibernate isn't mature enough to handle complex conditions like > this or am I wrong? I didn't found anything better then Criteria API + > NHLambdaExtensions yet... > > On 28 Dub, 12:24, Tuna Toksoz <[email protected] > <mailto:[email protected]>> wrote: > > However, my eyes hurt when reading criteria :) > > > > 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 1:23 PM, Filip Kinsky <[email protected] > <mailto:[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] > <mailto:[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://twitt... > > > > > > On Tue, Apr 28, 2009 at 12:40 PM, Filip Kinsky > <[email protected] <mailto:[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 -~----------~----~----~----~------~----~------~--~---
