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

"Take" doesn't work with GroupBy.

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Unknown Unknown
    • 2.15.1
    • 2.14.0
    • LINQ3
    • None

    Description

      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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: