开发者

Fluent mongo Count() performance

Given this wrapper:

    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
    {
        retu开发者_如何学Pythonrn this.GetQuery<TEntity>().AsQueryable().Count(criteria);
    }

If I call Count(), will the query be performed on the server as stated in the documentation here?

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


Yes. It will get executed server-side. You can verify this by turning the profiling up on your mongodb server and seeing what gets executed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜