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.
精彩评论