Skip to content

Latest commit

 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

MongoAsyncEnumerableAdapter

NuGet NuGet license

Provides an adapter from MongoDB's IAsyncCursor<TDocument> and IAsyncCursorSource<TDocument> to IAsyncEnumerable<T>

This allows plugging MongoDB's custom async iterators into the async LINQ ecosystem by wrapping IAsyncCursorSource<TDocument> or IAsyncCursor<TDocument> in an IAsyncEnumerable<T> implementation.

For example, iterating on a find result with await foreach:

IMongoCollection<Hamster> collection = // ...
IFindFluent<Hamster, Hamster> findFluent = collection.Find(hamster => hamster.Name == "bar");

await foreach (var hamster in findFluent.ToAsyncEnumerable())
{
    Console.WriteLine(hamster.Age);
}

Or any other async LINQ operator:

IMongoCollection<Hamster> collection = // ...

int groupCount = 
    await collection.AsQueryable().
        ToAsyncEnumerable().
        GroupBy(hamster => hamster.Age).
        CountAsync();

About

Provides an adapter from MongoDB's IAsyncCursor & IAsyncCursorSource to IAsyncEnumerable

Resources

Stars

20 stars

Watchers

3 watching

Forks

Releases

Used by

Contributors

Languages