I am completely fine with something like "1=2" since the problem are
combined statements like

session.Query<Foo>().Where(x => someIds.Contains(x.Id) ||
x.Name.StartsWith("A"));

which would then result in

select * from Foo where 1=2 or Name like 'A%'

which in turn yields an expected/correct/valid result

On Dec 27, 8:23 pm, Diego Mijelshon <[email protected]> wrote:
> If I'm not mistaken, the code is either
> src/NHibernate/Linq/Functions/QueryableGenerator.is (class
> CollectionContainsGenerator)
> or src/NHibernate/Linq/Visitors/ResultOperatorProcessors/ProcessContains.cs
> (the latter sounds more likely)
>
> However, consider Richard's comment to that issue:
>
> *[...] what SQL would you expect to be generated?*
>
> "where column in <empty>" is just like saying "where 1=2". The best
> workaround is to just return an empty list or null from your method if you
> get an empty list, without even bothering to go to the db.
>
>     Diego
>
> On Mon, Dec 27, 2010 at 18:43, Gabriel Schenker <[email protected]>wrote:
>
>
>
>
>
>
>
> > There is an open bug (NH-2400) regarding the fact that the NHibernate
> > 3.0 LINQ provider does not work correctly for empty collections when
> > creating an IN query, e.g.
>
> > session.Query<Foo>().Where(x => someIds.Contains(x.Id));
>
> > and "someIds" is empty. This leads to the exception "An empty
> > parameter-list generate wrong SQL; parameter name 'p1'".
>
> > We are currently moving from NHibernate 2.x to 3.0 GA and find that
> > this very bug causes us a lot of headache! We use such where
> > statements all over the place and it worked just fine with the LINQ
> > provider for NH 2.x.
>
> > Is there a fix available or a work around without us having to
> > refactor all our code...?
> > If no fix or workaround is available, then can somebody with a more
> > intimate knowledge of the LINQ provider give a hint where I would have
> > to go to change the code.
>
> > --
> > 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]<nhusers%[email protected] 
> > >
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nhusers?hl=en.

-- 
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