我有以下代码
IDocumentSession documentSession = store.OpenSession();
var schools = documentSession.Query<School>().Where(x => x.SchoolName == "My Primary School").ToList();
foreach (var school in schools)
{
Console.WriteLine(school);
}
schools = documentSession.Query<School>().Where(x => x.Id == "109940").ToList();
foreach (var school in schools)
{
Console.WriteLine(school.SchoolName); // returns My Primary School
}
当第一个查询运行时,虽然我在数据库中有一条匹配的记录,但没有返回任何记录。但是第二个查询返回我期望的记录。我将数据库作为嵌入式运行,我自己没有设置任何索引
更新:所以如果我自定义查询以等待非陈旧的结果它工作正常,我需要创建一个永久索引吗?