Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-940

Add ability to access sort, skip, limit, etc... for a LINQ query.

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.1
    • Affects Version/s: 1.8.3
    • Component/s: Linq
    • Labels:
      None
    • Fully Compatible

      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?

            Assignee:
            Unassigned Unassigned
            Reporter:
            mkennedy66996693 Michael Kennedy
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: