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/-/iUW5c70_hlkJ.
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