:))

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]> 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]> 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://twitt...
>
> > > 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to