Is AsQueryable method departed in new Mongodb C# driver 2.0rc?
19 October update:
MongoDB 2.1 driver is out https://github.com/mongodb/mongo-csharp-driver/releases/tag/v2.1.0
It supports LINQ:
LINQ
CSHARP-935 LINQ support has been rewritten and now targets the aggregation framework. It is a more natural translation and enables many features of LINQ that were previously not able to be translated.
Simply use the new AsQueryable method to work with LINQ.
18 September update:
MongoDB 2.1 driver RC should support it. See https://jira.mongodb.org/browse/CSHARP-935
Finally 2.1 rc came out. Great work!
Old answer:
No, AsQueryable is unsupported: https://jira.mongodb.org/browse/CSHARP-935
Type: Epic Status:OPEN Priority: Major - P3 Resolution: Unresolved
And from the hourse's mouth: Craig Wilson on the google forum
Yes, there is currently no AsQueryable on the new api. You can track this feature here (https://jira.mongodb.org/browse/CSHARP-935). We simply didn't have enough time to get it completed and tested thoroughly. It is scheduled for 2.1 and is a priority for us. Until then, we have integrated expression tree functionality into the Find and Aggregate methods (and some of the write methods for filtering) such that you may not need a full LINQ implementation. For instance, see the sample test class here as an example: https://github.com/mongodb/mongo-csharp-driver/blob/master/src/MongoDB.Driver.Tests/Samples/AggregationSample.cs#L77
I originally had the following using mongocsharp version 1.9x:
public IQueryable<T> SearchFor(Expression<Func<T, bool>> predicate)
{
return _collection.AsQueryable<T>()
.Where(predicate.Compile()).AsQueryable();
}
Was able to get the same results in version 2 using:
public async Task<List<T>> SearchFor(Expression<Func<T, bool>> predicate)
{
return await _collection.Find(Builders<T>.Filter.Where(predicate)).ToListAsync();
}
Hope it helps.