LINQ query that contains .Any() produces invalid SQL

Description

I have a very simple entity CostItem.
Here is my mapping:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test"
namespace="NHibernate.Test.NHSpecificTest.NH2911">
<class name="CostItem" table="CostItem" >
<id name="Id" access="nosetter.camelcase-underscore">
<generator class="identity" />
</id>
<property name="Units" />
</class>
</hibernate-mapping>

I am trying to write a LINQ query Q2 that returns all CostItem and exclude result set of another linq query Q1 .

var Q1 = (from ci in session.Query<CostItem>()
where ci.Id == 1
select ci);

var Q2 = (from ci in session.Query<CostItem>()
where !Q1.Any(c => c.Id == ci.Id)
select ci).ToArray();

Q2 produces invalid SQL:

select costitem0_.Id as Id0_,
costitem0_.Units as Units0_
from CostItem costitem0_
where not
(exists (select costitem1_.Id
from CostItem costitem1_
where costitem1_.Id=1
and costitem1_.Id=costitem1_.Id)
)

It seems that and costitem1_.Id=costitem1_.Id is wrong

should be costitem1_.Id=costitem0_.Id

Environment

None

Attachments

1

Activity

Show:

Oskar Berggren 
May 30, 2012 at 6:31 PM

Closing issues fixed in 3.3.1.CR1.

ValentinM 
October 11, 2011 at 10:03 PM

Unit test attached.

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created October 11, 2011 at 9:56 PM
Updated May 30, 2012 at 6:31 PM
Resolved November 14, 2011 at 1:51 PM
Who's Looking?