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

"Take" doesn't work with GroupBy.

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 2.15.1
    • Affects Version/s: 2.14.0
    • Component/s: LINQ3
    • Labels:
      None

      In V3, this LINQ query:

      Collection
         .AsQueryable()
         .GroupBy(doc => doc.Field)
         .Select(g => new { g.Key, Take = g.Take(6) })
         .ToList();

      Generates:

      [{ "$group" :

      { "_id" : "$Field" }

      }, { "$project" : { "Key" : "$_id", "Take" :

      { "$slice" : ["$$ROOT", 6] }

      , "_id" : 0 } }]

      But fails with:

      Command aggregate failed: First argument to $slice must be an array, but is of type: object.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            baris@saydag.com Baris Saydag
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: