[CSHARP-1472] ToListAsync() for IQueryable Created: 09/Nov/15  Updated: 09/Mar/16  Resolved: 09/Mar/16

Status: Closed
Project: C# Driver
Component/s: Linq
Affects Version/s: 2.0.1
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Dan Danneberg Assignee: Unassigned
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

In MongoDB.Driver.2.1.0\lib\net45\MongoDB.Driver.dll I have found the class MongoDB.Driver.Linq.MongoQueryable whih defines extension methods for IQueryable. I'm missing:

public static Task<List<TSource>> ToListAsync<TSource>(this IQueryable<TSource> source, CancellationToken cancellationToken = null)

Although:
public static Task<TSource> FirstAsync<TSource>(this IQueryable<TSource> source, CancellationToken cancellationToken = null)
is defined.

Workaround: Own extension class:
public static class MongoQueryableExtension
{
public static Task<List<T>> ToListAsync<T>(this IQueryable<T> queryable, CancellationToken cancellationToken = default(CancellationToken))

{ var mongoQueryable = queryable as IMongoQueryable<T>; if (mongoQueryable == null) throw new ArgumentException("Has to be an instance of IMongoQueryable", "queryable"); return mongoQueryable.ToListAsync(cancellationToken); }

}



 Comments   
Comment by Craig Wilson [ 09/Mar/16 ]

Hi Dan,

We have these extension methods defined on IMongoQueryable. We won't be adding them to the generic IQueryable method.

Craig

Generated at Wed Feb 07 21:39:42 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.