should I use batchSize in MONGODB Driver C# code example
Example 1: mongodb c# batch find
var filter = new BsonDocument();
var options = new FindOptions<BsonDocument>
{
BatchSize = 100
};
using (var cursor = await test.FindAsync(filter, options))
{
while (await cursor.MoveNextAsync())
{
var batch = cursor.Current;
foreach (var doc in batch)
{
}
}
}
Example 2: mongodb c# batch find
var filter = new BsonDocument();
var options = new FindOptions<BsonDocument>
{
BatchSize = 100
};
using (var cursor = await test.FindAsync(filter, options))
{
await cursor.ForEachAsync(doc =>
{
});
}