The equals operator works because that's the only case which can be
supported. It applies equality check to all properties.

>= is translated to Ge because that's what Ge means. *G*reather than or *e*qual
to.

It is not possible to support your operator overload, since that would
require that NHibernate could decompile your code.

/G

2016-04-19 10:52 GMT+02:00 Erik H <erikholman...@gmail.com>:

> So I just did a test...
>
> An equals operator in the where statement *does* work!
>
>                     .Where(ai => ai.AsapVerwerkingsPeriode* == *periodeVanaf
>> && ai.AsapVerwerkingsPeriode* == *periodeTm && ( //niet geblokkeerde
>> beschikbaarstellingen en premie inhoudingen
>>                         (ai.Type == AsapInputType.Beschikbaarstelling ||
>> ai.Type == AsapInputType.BrutoPremieInhouding || ai.Type ==
>> AsapInputType.NettoPremieInhouding) &&
>>                         ai.Uitkeringscomponent.Bron !=
>> UitkeringscomponentBron.HandmatigplanUC));
>
>
>>                     .Where(ai => ai.Uitkeringsplan.Contractnummer ==
>> contract || ai.Uitkeringsplan.Contractnummer == contract.PadLeft(20, '0'));
>
>
> Results in:
>
>> where (asapinput0_.AsapVerwerkingsPeriodeMaand = @p0 and
>> asapinput0_.AsapVerwerkingsPeriodeJaar = @p1) and
>> (asapinput0_.AsapVerwerkingsPeriodeMaand = @p2 and
>> asapinput0_.AsapVerwerkingsPeriodeJaar = @p3) and (asapinput0_.Type=@p4 or
>> asapinput0_.Type=@p5 or asapinput0_.Type=@p6) and uitkerings1_.Bron<>@p7
>> and (uitkerings2_.Contractnummer=@p8 or uitkerings2_.Contractnummer=@p9)
>
>
>
> Why is the *>=* is being translated in SQL to *ge*.... ? The fact stays
> the same that NHibernate creates an incorrect SQL Server Query. Is this
> worth reporting a bug?
>
>
> On Monday, April 18, 2016 at 10:38:10 PM UTC+2, Gunnar Liljas wrote:
>>
>> It comes from the fact that the old Linq provider (which has been
>> completely replaced), just mapped the Linq query to an ICriteria query,
>>
>> A >= B
>>
>> becomes
>>
>> Restrictions.Ge(A,B)
>>
>> which is converted to
>>
>> A.Property1 >= B.Property1 AND A.Property2 >= B.Property2 AND A.Property3
>> >= B.Property3 AND .....
>>
>>
>> You will have to rewrite your queries to explicitly query on both
>> properties. Either manually or by using an ExpressionVisitor.
>>
>> /G
>>
>> 2016-04-18 16:10 GMT+02:00 Erik H <erikho...@gmail.com>:
>>
>>> Okay, it might not be correct.... but where does the GE or LT comes
>>> from...? Any ideas?
>>>
>>>
>>> On Monday, April 18, 2016 at 3:31:26 PM UTC+2, Oskar Berggren wrote:
>>>
>>>>
>>>>
>>>> 2016-04-18 12:41 GMT+01:00 Erik H <erikho...@gmail.com>:
>>>>
>>>>>
>>>>>         public static bool operator >=(JaarEnMaand jaarEnMaand1,
>>>>>> JaarEnMaand jaarEnMaand2)
>>>>>>         {
>>>>>>             if (jaarEnMaand1.Jaar == jaarEnMaand2.Jaar)
>>>>>>             {
>>>>>>                 return (jaarEnMaand1.Maand >= jaarEnMaand2.Maand);
>>>>>>             }
>>>>>>             return (jaarEnMaand1.Jaar >= jaarEnMaand2.Jaar);
>>>>>>         }
>>>>>>
>>>>>>
>>>>
>>>>>
>>>>> *Model:*
>>>>>
>>>>>> public class AsapInput : Entity{
>>>>>
>>>>>         public virtual JaarEnMaand AsapVerwerkingsPeriode { get; set; }
>>>>>> }
>>>>>>
>>>>>
>>>>>
>>>>> *LINQ statement:*
>>>>>
>>>>>>                     .Where(ai => ai.AsapVerwerkingsPeriode >=
>>>>>> periodeVanaf && ai.AsapVerwerkingsPeriode <= periodeTm && ( //niet
>>>>>> geblokkeerde beschikbaarstellingen en premie inhoudingen
>>>>>>                         (ai.Type == AsapInputType.Beschikbaarstelling
>>>>>> || ai.Type == AsapInputType.BrutoPremieInhouding || ai.Type ==
>>>>>> AsapInputType.NettoPremieInhouding) &&
>>>>>>                         ai.Uitkeringscomponent.Bron !=
>>>>>> UitkeringscomponentBron.HandmatigplanUC));
>>>>>
>>>>>
>>>>>
>>>>>                     .Where(ai => ai.Uitkeringsplan.Contractnummer ==
>>>>>> contract || ai.Uitkeringsplan.Contractnummer == contract.PadLeft(20, 
>>>>>> '0'))
>>>>>
>>>>>
>>>>>
>>>>
>>>>>
>>>>> *CORRECT* Generated SQL where statment in *NHibernate 2.1.2.400*:
>>>>>
>>>>>> WHERE           ((
>>>>>>
>>>>>> this_.asapverwerkingsperiodemaand >= @p0
>>>>>>                                 AND
>>>>>> this_.asapverwerkingsperiodejaar >= @p1
>>>>>>
>>>>>
>>>>
>>>> But this is NOT correct! At least it doesn't match your C#
>>>> implementation for arbitrary values of periods:
>>>> C#     2005-06 >= 2004-07 => ((2005==2004 AND 06>=07)) OR (2005>=2004)
>>>> => TRUE
>>>> SQL  2005-06 >= 2004-07 => (2005>=2004 AND 06>=07) => FALSE
>>>>
>>>>
>>>> /Oskar
>>>>
>>>>
>>>>
>>>> --
>>> 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 nhusers+u...@googlegroups.com.
>>> To post to this group, send email to nhu...@googlegroups.com.
>>> 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 nhusers+unsubscr...@googlegroups.com.
> To post to this group, send email to nhusers@googlegroups.com.
> 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 nhusers+unsubscr...@googlegroups.com.
To post to this group, send email to nhusers@googlegroups.com.
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to