MongoCollection<BsonDocument> collection = db.GetCollection("TestCollection");
MongoCursor<BsonDocument> cursor = collection.FindAll();
List<BsonDocument> list = cursor.toList();
This is very slow executing. MongoCursor converting to a List is very slow, but if I use the following code:
MongoCollection<T> collection = db.GetCollection<T>("TestCollection");
MongoCursor<T> cursor = collection.findAll();
List<T> entities = cursor.toList();
The above code is much faster. Why is MongoCursor converting to a List so slow? I want to use BsonDocument. How can I solve this problem?
There's a bug with driver 1.8.0 ~ 1.8.2. We run into the same issue some days ago and reported in the MongoDb JIRA CSHARP-822. Upgrade to 1.8.3+ is supposed to resolve this issue.