[CSHARP-3214] Missing extension methods for AsyncCursorSource and IAsyncCursor Created: 24/Sep/20 Updated: 27/Oct/23 Resolved: 28/Sep/20 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Mohamad Javad Ebrahimi | Assignee: | Robert Stam |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Why classes `IAsyncCursorSourceExtensions` and `IAsyncCursorExtensions` have no extension methods for `CountAsync`, `AverageAsync`, `MinAsync`, `MaxAsync` `SumAsync`, etc.? |
| Comments |
| Comment by Robert Stam [ 28/Sep/20 ] | |||
|
Methods like `CountAsync`, `AverageAsync`, `MinAsync`, `MaxAsync` , `SumAsync` etc... are LINQ methods that are intended to execute server side. You want to use these methods as part of a LINQ query. For example, the following LINQ query executes entirely server side and only the count is returned to the client:
You can use existing driver APIs to count the matching documents client side if you wish (though I would not recommend that):
But note that:
I can't think of any case where you would want to do the count client side rather than server side.
| |||
| Comment by Esha Bhargava [ 28/Sep/20 ] | |||
|
mj.ebrahimi72@gmail.com Thanks for reporting this! We'll have a look at this soon and get back to you. |