很抱歉给你一个 MongoDb for Cshare 驱动程序(Samus)的问题,你能帮忙看看吗?
using (Mongo mongo = new Mongo(config.BuildConfiguration()))
{
mongo.Connect();
try
{
var db = mongo.GetDatabase("MyCollection");//Collection 's count > 500,000,000
var collection = db.GetCollection<BasicData>();
Console.WriteLine("Count by LINQ on typed collection: {0}", collection.Linq().Count(x => x.Id > 1));////error ,timeout
Console.WriteLine("Count by not LINQ on typed collection: {0}", collection.Count()); //no condition is ok
Console.ReadKey();
}
finally{
mongo.Disconnect();
} }
使用 Mongodb 外壳:
db.collection.find(condition).count() 或 db.collection.count(condition); //非常慢