views:

11

answers:

0

Hello all,

I have the following HQL query:

return Session.CreateQuery("from Player p where p.Sex = :teamSex and p.Visible and not exists (from PlayerInTeam pit where pit.Player = p and pit.Roster.Team = :teamId)")
    .SetParameter("teamId", team.Id)
    .SetParameter("teamSex", team.Sex)
    .Enumerable<Player>();

How would you write it using the QueryOver syntax of NH 3.0 ?

At the moment, I have this:

return Session.QueryOver<Player>()
    .Where(p => p.Sex == team.Sex)
    .WithSubquery.WhereNotExists(QueryOver.Of<PlayerInTeam>().Where(pit => pit.Roster.Team == team))
    .List();

But this produces this exception : NHibernate.QueryException: Cannot use subqueries on a criteria without a projection

Thanks in advance

Mike