我正在使用 LINQ to NHibernate 查询 SQLite 数据库。
Person
是一个包含 Id 和 Name 的实体:
public class Person
{
public Guid Id { get; private set; }
public string Name { get; private set; }
}
假设我的 db 表包含一个名为“ John ”的人。
此测试按预期工作:
var query = from item in session.Linq<Person>()
where (item.Name == "Mike")
select item;
// no such entity should exist
Assert.IsFalse(query.Any());
但是这个失败了:
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());
我错过了什么?