Should be possible, I'm just having a quick look at it now but I'm not
sure what the "g.GroupID not in ..." construct is for. What are the
semantics that you're trying to achieve please? A list of users who
aren't in a group? *If* that's the case, I'd suggest a different query
structure along the lines of "select xxx from Users where UserId not in
(select distinct UserId from GroupMembership where GroupId = :id)" - a
quick 'n' dirty test suggests something like
var membershipQuery = QueryOver.Of<GroupMembership>()
.Where(x => x.Id == groupId)
.Select(x => x.UserId);
var userQuery = NhSession.QueryOver<User>()
.WithSubquery.WhereProperty(x => x.Id)
.NotIn(membershipQuery);
var users = userQuery.List();
/Pete
From: [email protected] [mailto:[email protected]] On
Behalf Of Hon Guin Lee
Sent: 11 December 2012 09:35
To: [email protected]
Subject: [nhusers] NHibernate Query using QueryOver with Left Outer
Joins and Where Clauses
Hi there,
I am writing the follow as an NHibernate Query but cannot find a
solution using QueryOver: -
IQuery query = SessionFactoryContext.
GetCurrentSession().CreateSQLQuery("SELECT
s.UserID,Username,Email,Password,FirstName,LastName,Address1,Address2,Ci
ty,County,PostalCode,Country FROM [dbl].[dbo].[User] s LEFT OUTER JOIN
[dbl].[dbo].[groupmembership] g ON s.UserrID = g.UserrID WHERE g.UserID
IS NULL OR (g.GroupID NOT IN (" + groupID + ") )")
.SetResultTransformer(Transformers.AliasToBean(typeof(User)));
return (IList<Subscriber>)query.List<User>();
Is there any way possible that this can be written as an NHibernate
query?
Many thanks for your help,
--
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/-/yGnA0W_SJWAJ.
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.
!DSPAM:1,50c742d280905534910970!
--
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.