[CSHARP-940] Add ability to access sort, skip, limit, etc... for a LINQ query. Created: 24/Mar/14  Updated: 22/Apr/15  Resolved: 22/Apr/15

Status: Closed
Project: C# Driver
Component/s: Linq
Affects Version/s: 1.8.3
Fix Version/s: 2.1

Type: Improvement Priority: Minor - P4
Reporter: Michael Kennedy Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: Rewrite Linq
Backwards Compatibility: Fully Compatible

 Description   

Consider either of the following:

MongoQueryable<T> mongoQuery = query as MongoQueryable<T>;
if (mongoQuery != null)
return mongoQuery.GetMongoQuery();

MongoCursor<T> mongoCursor = query as MongoCursor<T>;
if (mongoCursor != null)
return mongoCursor.Query;

Calling ToString on either mongoQuery.GetMongoQuery() or mongoCursor.Query. It will return the where clause of a query. But as far as I can tell, there is no way to access other parts of the query such as sort, limit, skip, projects, etc.

So if I had:

var query =
(from p in people
where p.age > 21
orderby p.Name descending)
.Skip(20)
.Take(10)

The query part is {age: {$gt: 21} } but I haven't found a way to access the rest of the query. Am I missing it or is this aspect inaccessible from the outside?



 Comments   
Comment by Craig Wilson [ 22/Apr/15 ]

Michael,

We are only targeting the aggregation framework with the LINQ rewrite. As such, you'll have access to all the generated stages of the pipeline as BsonDocuments which will obviously include the skips and limits. I'll be working on documentation shortly to demonstrate how to extract this information.

CRaig

Comment by Michael Kennedy [ 04/Aug/14 ]

Great, thanks Craig!

Comment by Craig Wilson [ 04/Aug/14 ]

Forgot all these things were public

Our springs are 3 weeks long and we are 1 week into Sprint 6, so roughly 5 weeks from now that'll start.

Comment by Michael Kennedy [ 04/Aug/14 ]

Craig,

I'm seeing a lot of features I've requested making it into Sprint 8. That'll be awesome. Do you have a time frame for sprint 8?

Comment by Michael Kennedy [ 24/Mar/14 ]

Thank you Craig!

Comment by Craig Wilson [ 24/Mar/14 ]

Thanks Mike. This is definitely planned in the Linq rewrite and, I believe is already there, so this is definitely important. We'll keep this open to track it and so you can verify once we publish an early release of the feature.

Thanks,
CRaig

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