I think this would work:
Course courseAlias = null;
User userAlias = null;
var statesForUser =
QueryOver.Of<Enrollment>()
.JoinAlias(e => e.User, () => userAlias)
.JoinAlias(e => e.Course, () => courseAlias)
.Where(() => userAlias.UserName == “Hoang”)
.Select(() => courseAlias.StateName);
var courses =
session.QueryOver<Course>()
.WithSubquery.WhereProperty(c => c.StateName).In(statesForUser)
.List();
http://nhforge.org/blogs/nhibernate/archive/2009/12/17/queryover-in-nh-3-0.aspx#Subqueries
Regards,
Richard
From: Hoang Tang
Sent: Sunday, October 31, 2010 5:10 AM
To: [email protected]
Subject: [nhusers] How do I do a subselect with QueryOver?
consider the following Hql I would like to convert it to QueryOver
from Course c where c.StateName in (select e.Course.StateName from Enrollment e
where e.User.UserName ='Hoang' )
--
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.