I have updated to the latest version NHibernate, built on the trunk. I’m using it for a pet project that uses latest NHibernate 3.0 functionalities. Using the new QueryOver API is my favourite new functionality but using it might be tricky sometimes. Do you think you can find out what is the problem with this code?

1
2
3
4
5
6
7
8
9
10
11
12
13
private User FindValidUser(string username, string password)
{
using (var session = GetCurrentSession())
{
var users = session.QueryOver<User>()
.Where(u => u.IsActive)
.And(u => u.Username == username.ToLower(CultureInfo.InvariantCulture))
.And(u => u.PassPhrase == password)
.List();

return users.Count == 0 ? null : users[0];
}
}