gpt4 book ai didi

linq - 流畅的 mongo Count() 性能

转载 作者:可可西里 更新时间:2023-11-01 09:37:54 29 4
gpt4 key购买 nike

给定这个包装器:

    public MongoCollection<TEntity> GetQuery<TEntity>() where TEntity : class
{
var query = DataBase.GetCollection<TEntity>(typeof(TEntity).Name + "s");
return query;
}

public long Count<TEntity>(System.Linq.Expressions.Expression<Func<TEntity, bool>> criteria) where TEntity : class
{
return this.GetQuery<TEntity>().AsQueryable().Count(criteria);
}

如果我调用 Count(),是否会按照文档中所述在服务器上执行查询 here

var count = db<MyEntity>.Count(x => x.Foo = "foo");

最佳答案

是的。它将在服务器端执行。您可以通过在您的 mongodb 服务器上打开分析并查看执行的内容来验证这一点。

关于linq - 流畅的 mongo Count() 性能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6273122/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com