Oh, and as a work-around, I was able to use

    session.Query<Person>().Where(o => o.Employee.EmployeeId != null)

However, in my application, I use a data access interface with an 
NHibernate implementation for integration testing and production and a 
LINQ-to-Objects implementation for unit testing, so that doesn't work.  I 
ended up selected all of the PersonId into a list from an 
IQueryable<Employee> and checking to see if that list did (or didn't) 
contain the person ID, something like:

    var personWithEmployeePersonIds = wrapper.Query<Employee>().Select(e => 
e.Person.PersonId).ToList();
    var people wrapper.Query<Person>().Where(o => 
!personWithEmployeePersonIds.Contains(o.personId)).ToList();

On Tuesday, January 8, 2013 8:45:25 AM UTC-5, Don wrote:
>
> Thanks, Oskar.  I'll try to get that done when I have a chance.  I altered 
> the code locally based on the issue attachment to include my scenario, and 
> they do appear to be the same.
>
> On Monday, January 7, 2013 3:33:21 PM UTC-5, Oskar Berggren wrote:
>>
>> Sounds similar to this one: 
>> https://nhibernate.jira.com/browse/NH-3117 
>>
>> A way to help with this is to write a test case suitable for the 
>> NHibernate code base, possibly based on the code found in the 
>> attachment to issue NH-3117. 
>> See this 
>>
>> http://nhforge.org/blogs/nhibernate/archive/2008/10/04/the-best-way-to-solve-nhibernate-bugs-submit-good-unit-test.aspx
>>  
>>
>> Or fork NHibernate on github and submit the test case directly as a 
>> pull request. 
>>
>> /Oskar 
>>
>>
>> 2013/1/7 mysterd429 <[email protected]>: 
>> > All, 
>> > 
>> > This happens even if I greatly simplify: nh.Query<Parent>().Where(p => 
>> > p.OnetoOneChild == null).ToList() also generated the check for 
>> PARENT_ID IS 
>> > NULL. 
>> > 
>> > Thanks. 
>> > 
>> > 
>> > On Monday, January 7, 2013 2:08:49 PM UTC-5, mysterd429 wrote: 
>> >> 
>> >> Hi all. 
>> >> 
>> >> I'm trying to execute a query using LINQ-to-NH, and the SQL that gets 
>> >> generated seems wrong to me.  The following statement: 
>> >> 
>> >> nh.Query<ManyToOneChild>().Where(a => a.Parent.OneToOneChild != 
>> >> null).ToList() 
>> >> 
>> >> generates the following SQL (which I formatted and removed the aliases 
>> >> from): 
>> >> 
>> >> select 
>> >>     MANY_TO_ONE_CHILD.MANY_TO_ONE_CHILD_ID 
>> >>   , MANY_TO_ONE_CHILD.PROPERTY_A 
>> >>   , MANY_TO_ONE_CHILD.PARENT_ID 
>> >>   , MANY_TO_ONE_CHILD.PROPERTY_C_GRANTPARENT_ID 
>> >> from 
>> >>     MANY_TO_ONE_CHILD 
>> >> inner join 
>> >>     PARENT 
>> >> on 
>> >>     MANY_TO_ONE_CHILD.PARENT_ID = parent.PARENT_ID 
>> >> where 
>> >>     PARENT.PARENT_ID is not null 
>> >> 
>> >> My mapping file has the following: 
>> >> 
>> >> <class name="OneToOneChild" table="ONE_TO_ONE_CHILD" lazy="true" > 
>> >>     <many-to-one name="Parent" class="Parent" unique="true"> 
>> >>         <column name="PARENT_ID" /> 
>> >>     </many-to-one> 
>> >> </class> 
>> >> <class name="Parent" table="PARENT" lazy="true" > 
>> >>     <one-to-one name="OneToOneChild" class="OneToOneChild" 
>> >> property-ref="Parent" /> 
>> >> </class> 
>> >> 
>> >> I would have expected a sub-query or a join to check the 
>> ONE_TO_ONE_CHILD. 
>> >> 
>> >> Any ideas? 
>> >> 
>> >> Thanks! 
>> > 
>> > -- 
>> > You received this message because you are subscribed to the Google 
>> Groups 
>> > "nhusers" group. 
>> > To view this discussion on the web visit 
>> > https://groups.google.com/d/msg/nhusers/-/cfTFjqNYfrkJ. 
>> > 
>> > 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. 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/nhusers/-/oAQTs-5_jnoJ.
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