-
Type:
Question
-
Resolution: Works as Designed
-
Priority:
Major - P3
-
None
-
Affects Version/s: 3.2.0
-
Component/s: None
-
None
-
None
-
Dotnet Drivers
-
None
-
None
-
None
-
None
-
None
-
None
Summary
As of c# driver 3.2.0, using the "Take" operator to perform a slice when querying via the queryable interface no longer works.
How to Reproduce
See attached for a minimal console app that reproduces the behavior. Notable lines:
widgetBoxCollection.InsertOne(new WidgetBox([new Widget("A"), new Widget("B"), new Widget("C")])); var lastTwoWidgets = await widgetBoxCollection.AsQueryable() .Where(_ => true) .SelectMany(j => j.Widgets.Take(-2)) .ToListAsync(); var lastTwoWidgets2 = (await widgetBoxCollection.AsQueryable() .Where(_ => true) .Select(j => j.Widgets.Take(-2)) .ToListAsync()).Single(); Console.WriteLine($"Widgets result 1: [{string.Join(",", lastTwoWidgets.Select(w => w.Name))}]"); Console.WriteLine($"Widgets result 2: [{string.Join(",", lastTwoWidgets2.Select(w => w.Name))}]");
Output on 3.1.0:
Widgets result 1: [B,C] Widgets result 2: [B,C]
Output on 3.2.0:
Widgets result 1: [] Widgets result 2: []
- is related to
-
CSHARP-5526 Suport SkipLast and TakeLast in LINQ expressions
-
- Backlog
-