Unofficial IAsyncEnumerable support for MongoDB C# Driver.
$ dotnet add package MongoDB.Driver.Linq.AsyncEnumerableUnofficial IAsyncEnumerable support for MongoDB C# Driver.
Provides ToAsyncEnumerable() extensions for MongoDB IAsyncCursor and IAsyncCursorSource.
MongoDB.Driver.Linq namespace by using MongoDB.Driver.LinqToAsyncEnumerable() extension for either IAsyncCursor or IAsyncCursorSourceToAsyncEnumerable()Find()using MongoDB.Bson;
using MongoDB.Driver;
using MongoDB.Driver.Linq;
var client = new MongoClient();
var database = client.GetDatabase("ExampleDatabase");
var collection = database.GetCollection<BsonDocument>("ExampleCollection");
await foreach (var document in collection.Find(_ => true).ToAsyncEnumerable())
{
Console.WriteLine(document.ToString());
}
Aggregate()using MongoDB.Bson;
using MongoDB.Driver;
using MongoDB.Driver.Linq;
var client = new MongoClient();
var database = client.GetDatabase("ExampleDatabase");
var collection = database.GetCollection<BsonDocument>("ExampleCollection");
await foreach (var document in collection.Aggregate().ToAsyncEnumerable())
{
Console.WriteLine(document.ToString());
}