I am trying to use ICriteria to create a query with join state. The SQL I'm trying to create should look like this:
SELECT c.ClientID FROM Client c LEFT OUTER JOIN ClientContact t on c.ClientID = t.ClientID AND t.ContactType = 'Email'
If I use criteria such as
m_ClientRepository.QueryAlias("client") .CreateCriteria("client.Contacts", "c", JoinType.LeftOuterJoin) .Add(Restrictions.Eq("c.ContactType", ContactType.Email));
It will generate sql, below which I do not want.
SELECT c.ClientID FROM Client c LEFT OUTER JOIN ClientContact t on c.ClientID = t.ClientID WHERE t.ContactType = 'Email'
Is there a way to do this using ICriteria or HQL if ICriteria is not possible?
Edit: I found that nHibernate 2.1 (which I use) now resolves this . However, I'm not sure about ICriteria, these are my preferences.
Craig source share