Linq to NHibernate using Queryable.Where predicate
- by Groo
I am querying an SQLite database using LINQ to NHibernate.
Person is an entity containing an Id and a Name:
public class Person
{
public Guid Id { get; private set; }
public string Name { get; private set; }
}
Let's say my db table contains a single person whose name is "John".
This test works as expected:
var query = from item in session.Linq<Person>()
where (item.Name == "Mike")
select item;
// no such entity should exist
Assert.IsFalse(query.Any());
but this one fails:
var query = from item in session.Linq<Person>()
select item;
query.Where(item => item.Name == "Mike");
// following line actually returns the
// "John" entry
Assert.IsFalse(query.Any());
What am I missing?