[CSHARP-4048] "Take" doesn't work with GroupBy. Created: 11/Feb/22  Updated: 28/Oct/23  Resolved: 24/Mar/22

Status: Closed
Project: C# Driver
Component/s: LINQ3
Affects Version/s: 2.14.0
Fix Version/s: 2.15.1

Type: Bug Priority: Unknown
Reporter: Baris Saydag Assignee: Robert Stam
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: CSHARP-3615

 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.



 Comments   
Comment by Githook User [ 04/May/22 ]

Author:

{'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}

Message: CSHARP-4048: "Take" doesn't work with GroupBy.
Branch: v2.15.x
https://github.com/mongodb/mongo-csharp-driver/commit/a34ab83fe5c722f8824188546ef1a2d9eb13ca3c

Comment by Githook User [ 04/May/22 ]

Author:

{'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}

Message: CSHARP-4048: Test ALL IEnumerable extension methods against IGrouping.
Branch: v2.15.x
https://github.com/mongodb/mongo-csharp-driver/commit/91b54b774ca32c3c1a2dc143c9e98916cfd706c6

Comment by Githook User [ 24/Mar/22 ]

Author:

{'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}

Message: CSHARP-4048: Test ALL IEnumerable extension methods against IGrouping.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/370c033f1ca9142b89107c7ec651b7186536779e

Comment by Githook User [ 24/Mar/22 ]

Author:

{'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}

Message: CSHARP-4048: "Take" doesn't work with GroupBy.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/6ada045e96666599ff53388bbce392b65485c323

Comment by Dmitry Lukyanov (Inactive) [ 11/Feb/22 ]

Hello baris@saydag.com , thanks for the report, we will investigate it and come back to you.

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