I think you need a projection (select) on the sub-query:
.WithSubquery.WhereExists(
QueryOver.Of<PlayerInTeam>()
.Where(pit => pit.Roster.Team == team)
.Select(pit => pit.Id))
-----Original Message-----
From: Michael Delva
Sent: Wednesday, October 27, 2010 1:58 PM
To: nhusers
Subject: [nhusers] Convert a HQL query with QueryOver
Hello all,
I have this small query, written in HQL :
return Session.CreateQuery("from Player p where p.Visible and exists
(from PlayerInTeam pit where pit.Player = p and pit.Roster.Team
= :teamId)")
.SetParameter("teamId", team.Id)
.Enumerable<Player>();
I'd like to write it using the new QueryOver syntax.
Currently, I have:
return Session.QueryOver<Player>()
.Where(p => p.Visible)
.WithSubquery.WhereExists(QueryOver.Of<PlayerInTeam>().Where(pit
=> pit.Roster.Team == team))
.List();
But this throws this exception:
NHibernate.QueryException: Cannot use subqueries on a criteria without
a projection.
Could you tell me what's wrong?
Thanks in advance
--
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.