I don't think these operators have ever been supported on multi-column user types. Note that the behaviour you show for 2.1.2.400 also doesn't match the implementation in your operator>().
/Oskar 2016-04-18 7:56 GMT+01:00 Erik H <[email protected]>: > I've got an struct that implements some operators. > > public struct YearAndMonth{ >> private int _month; >> /// <summary> >> /// Month, between 1 and 12. >> /// </summary> >> public int Month >> { >> get >> { >> if (_month == 0) >> { >> _month = 1; >> } >> return _month; >> } >> private set // for NHibernate >> { >> if (value < 1 || value > 12) >> { >> throw new ArgumentOutOfRangeException("value"); >> } >> _month = value; >> } >> } >> private int _year; >> /// <summary> >> /// Year, between 1 and 9999. >> /// </summary> >> public int Year >> { >> get >> { >> if (_year == 0) >> { >> _year = 1; >> } >> return _year; >> } >> private set // for NHibernate >> { >> if (value < 1 || value > 9999) >> { >> throw new ArgumentOutOfRangeException("value"); >> } >> _year = value; >> } >> } >> > // This is just one of the operators, others are implemented too!! >> > > public static bool operator >(YearAndMonth obj1, YearAndMonth obj2) >> { >> if (obj1.Year == obj2.Year ) >> { >> return (obj1.Month > obj2.Month); >> } >> return (obj1.Year > obj2.Year); >> } >> } > > > My class looks a bit like this: > > class MyObj { >> public YearAndMonth Period {get; set;} >> } > > > I've got a where statement like this: > > .Where(_ => _.Period >= startPeriod && _.Period <= endPeriod) > > > When NHibernate translates the where statement it generates strange SQL > and throws a GenericADOException: > > WHERE ( >> myobj0_.periodmonth ge @p0 >> AND myobj0_.periodyear ge @p1) >> AND ( >> myobj0_.periodmonth le @p2 >> AND myobj0_.periodyear le @p3) > > > How can I get my where statement working without modifying the Linq > statements? I've upgraded NHibernate from version 2.1.2.400 to 4.0.4.400 > > > Where statement that is produced by NHibernate 2.1.2.400 with NHibernate.Linq > 1.1.0.1001: > >> >> WHERE ( >> this_.periodmonth >= @p0 >> AND this_.periodyear >= @p1 >> AND this_.periodmonth <= @p2 >> AND this_.periodyear <= @p3) > > > The configured dialect is NHibernate.Dialect.MsSql2008Dialect and > driver_class is NHibernate.Driver.SqlClientDriver. > > How can I make NHibernate generate the 'old' >= and <= ?? > > -- > 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 https://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 https://groups.google.com/group/nhusers. For more options, visit https://groups.google.com/d/optout.
