Linq ravendb计数查询不等于列表计数
ravendb查询为count方法和tolist()返回不同的结果。count 查询1(返回9):Linq ravendb计数查询不等于列表计数,linq,count,ravendb,Linq,Count,Ravendb,ravendb查询为count方法和tolist()返回不同的结果。count 查询1(返回9): var count=session.Query()。其中(x=>x.RequestType==RequestType.Db&&x.BelongTo==oaname)。ToList().count; 查询2(返回44): var count=session.Query(); 索引定义: public class ByFormNameIndex : AbstractIndexCreationTas
var count=session.Query()。其中(x=>x.RequestType==RequestType.Db&&x.BelongTo==oaname)。ToList().count;
查询2(返回44):
var count=session.Query();
索引定义:
public class ByFormNameIndex : AbstractIndexCreationTask<MobileForm>
{
public ByFormNameIndex()
{
Map = mobileForms => from form in mobileForms
select new
{
form.FormName,
form.BelongTo,
form.RequestType,
form.CreateTime,
form.Uuid
};
Analyzers.Add(x => x.FormName, "Lucene.Net.Analysis.PanGu.PanGuAnalyzer,PanGu.Lucene.Analyzer, Version=1.3.1.0, Culture=neutral, PublicKeyToken=null");
Indexes.Add(x => x.FormName, FieldIndexing.Analyzed);
Indexes.Add(x => x.BelongTo, FieldIndexing.NotAnalyzed);
Indexes.Add(x => x.RequestType, FieldIndexing.NotAnalyzed);
Indexes.Add(x => x.Uuid, FieldIndexing.NotAnalyzed);
}
公共类ByFormNameIndex:AbstractIndexCreationTask
{
公共ByFormNameIndex()
{
Map=mobileForms=>来自mobileForms中的表单
选择新的
{
form.FormName,
表格:BelongTo,
form.RequestType,
form.CreateTime,
表格Uuid
};
Analyzers.Add(x=>x.FormName,“Lucene.Net.Analysis.PanGu.PanGuAnalyzer,PanGu.Lucene.Analyzer,Version=1.3.1.0,Culture=neutral,PublicKeyToken=null”);
index.Add(x=>x.FormName,FieldIndexing.Analyzed);
添加(x=>x.BelongTo,FieldIndexing.NotAnalyzed);
index.Add(x=>x.RequestType,FieldIndexing.NotAnalyzed);
添加(x=>x.Uuid,FieldIndexing.NotAnalyzed);
}
}
query1返回正确的计数,那么此to方法的区别是什么?显示我新建以重建索引以获得正确的结果?这是设计的。
Count()
将显示总计数。
ToList()
只提供第一页。然后你就可以得到计数。你能提供一个失败的测试吗?ravendb.net/docs/samples/raven-tests/createRavenTests默认页面大小为9?我认为托利斯特应该承担更多的责任。
var count = session.Query<MobileForm,ByFormNameIndex>().Where(x => x.RequestType == RequestType.Db && x.BelongTo == oaname).Count();
public class ByFormNameIndex : AbstractIndexCreationTask<MobileForm>
{
public ByFormNameIndex()
{
Map = mobileForms => from form in mobileForms
select new
{
form.FormName,
form.BelongTo,
form.RequestType,
form.CreateTime,
form.Uuid
};
Analyzers.Add(x => x.FormName, "Lucene.Net.Analysis.PanGu.PanGuAnalyzer,PanGu.Lucene.Analyzer, Version=1.3.1.0, Culture=neutral, PublicKeyToken=null");
Indexes.Add(x => x.FormName, FieldIndexing.Analyzed);
Indexes.Add(x => x.BelongTo, FieldIndexing.NotAnalyzed);
Indexes.Add(x => x.RequestType, FieldIndexing.NotAnalyzed);
Indexes.Add(x => x.Uuid, FieldIndexing.NotAnalyzed);
}