I have a SQL Query which works in SQL Management Studio:
Select Id From table t Where t.Date= (Select Max(Date) From ( Select * From table where ReferenceId = xy) u)
Reason is, from all entries with a certain foreign key, I want to receive the one with the highest date.
I tried to reform this Query for use in NHibernate, and I got
IQuery query = session.CreateQuery(String.Format(
@"Select t.Id
From table t
Where t.Date =
(Select Max(Date)
From (Select *
From table t where t.ReferenceItem.Id = " + item.ReferenceItem.Id + ")u)"));
I get the error message: "In expected"
How do I have to form the NHibernate query? What does the "In" mean?