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

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

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: 1.8.3
    • Fix Version/s: 2.1
    • Component/s: Linq
    • Labels:
      None

      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?

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: