Understanding the changes in MongoDB new C# driver (Async and Await)

前端 未结 2 1355
日久生厌
日久生厌 2021-02-08 12:12

The new C# driver is totally Async and in my understanding twists a little bit the old design patterns such as DAL in n-tier architecture.

In my Mongo DALs I use to do:<

2条回答
  •  没有蜡笔的小新
    2021-02-08 12:17

    In my case: When I got this error:

    The source IQueryable doesn't implement IAsyncEnumerable. Only sources that implement IAsyncEnumerable can be used for Entity Framework asynchronous operations.

    I have implemented the async where function for mongodb as follows.

    public async Task> Where(Expression> expression = null)
    {
         return await context.GetCollection(typeof(TEntity).Name, expression).Result.ToListAsync();
    }
    

提交回复
热议问题