I used session.enablefilter or something along them lines along with a parameter just before my hql or criteria.
Provides the correct sql for me anyway Sent from my HTC ----- Reply message ----- From: "Craig van Nieuwkerk" <[email protected]> To: <[email protected]> Subject: [nhusers] Condition in join clause Date: Fri, Feb 11, 2011 00:02 I don't think a filter will work because the value is a parameter that is passed to the query. Is this correct? Craig. On Fri, Feb 11, 2011 at 10:58 AM, <[email protected]> wrote: Not sure if you want to do it this way but I have used filters in the past to achieve a and clause on a left outer join. Paul Sent from my android device. -----Original Message----- From: Craig van Nieuwkerk <[email protected]> To: [email protected] Sent: Thu, 10 Feb 2011 23:12 Subject: [nhusers] Condition in join clause I am using NHibernate 3.0 with QueryOver. I have the following query var query = Session.QueryOver<CustomFieldGroup>(() => customFieldGroup) .JoinAlias(() => customFieldGroup.Organisation, () => organisation) .JoinAlias(() => customFieldGroup.Fields, () => customField) .Left.JoinQueryOver(() => customField.Values, () => customFieldValue).And(() => customFieldValue.EntityId == 32) .Where(() => organisation.Code == 'Demo' && customFieldGroup.EntityType == 'Client') .OrderBy(() => customFieldGroup.OrderBy).Asc .OrderBy(() => customField.OrderBy).Asc .List<CustomFieldGroup>().ToList(); This generates the following query SELECT * FROM dbo.CustomFieldGroup this_ inner join dbo.CustomField customfiel2_ on this_.CustomFieldGroupId=customfiel2_.CustomFieldGroupId left outer join dbo.CustomFieldValue customfiel3_ on customfiel2_.CustomFieldId=customfiel3_.CustomFieldId inner join dbo.Organisation organisati1_ on this_.OrganisationId=organisati1_.OrganisationId WHERE customfiel3_.EntityId = 32 and (organisati1_.Code = 'Demo' and this_.EntityType = 'Client') ORDER BY this_.OrderBy asc, customfiel2_.OrderBy asc but what I really want is SELECT * FROM dbo.CustomFieldGroup this_ inner join dbo.CustomField customfiel2_ on this_.CustomFieldGroupId=customfiel2_.CustomFieldGroupId left outer join dbo.CustomFieldValue customfiel3_ on customfiel2_.CustomFieldId=customfiel3_.CustomFieldId and customfiel3_.EntityId = 32 inner join dbo.Organisation organisati1_ on this_.OrganisationId=organisati1_.OrganisationId WHERE (organisati1_.Code = 'Demo' and this_.EntityType = 'Client') ORDER BY this_.OrderBy asc, customfiel2_.OrderBy asc The difference is the condition has been moved from the where clause to the left join. Is there any way to do this? Craig -- 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. -- 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. -- 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. -- 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.
