[CSHARP-575] MapReduce(query, map, reduce) should have overload that takes an IQueryable<T> for query Created: 19/Sep/12  Updated: 20/Mar/14  Resolved: 12/Nov/12

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

Type: New Feature Priority: Minor - P4
Reporter: Anne Epstein Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Many collection operations that take a query can take either an IMongoQuery or an IQueryable<T>. MapReduce only has the option of IMongoQuery and it should alternatively be able to take an IQueryable<T> for filtering.



 Comments   
Comment by Craig Wilson [ 12/Nov/12 ]

Cool. Will close. You can always write an extension method for that piece.

Comment by Anne Epstein [ 12/Nov/12 ]

Yes, this issue can be closed. In my application, we pass in Linq-style filtering expressions from places that do not have Mongo references into our internal querying libraries that handle those queries. (keeping core logic away from hard Mongo dependencies) Simple queries with the Mongo Linq libraries can work directly with these expressions, but this pattern did not work when we hit a case requiring MapReduce, which requires the Mongo-specific IMongoQuery. We got around this when we discovered it was possible to get an IMongoQuery from an mongo-independent IQueryable, like so:

((MongoQueryable<T>) myQueryable).GetMongoQuery()

It would still be nice to call directly with the IQueryable and save a line of code, but with the conversion above, we didn't have to rework our architecture, so it's really not a problem.

Thanks for following up!

Comment by Craig Wilson [ 12/Nov/12 ]

Anne, is Robert's suggestion above what you were thinking? If so, we'd like to close this issue.

Comment by Robert Stam [ 24/Sep/12 ]

I don't see any methods in MongoCollection that take an IQueryable<T> parameter.

You can always use the typed Query builder to create an IMongoQuery, like this:

var query = Query<C>.EQ(c => c.X, 123);
var map = "...";
var reduce = "...";
var result = collection.MapReduce(query, map, reduce);

Is that what you had in mind?

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