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.
