Skip to content

Commit 015dc3d

Browse files
committed
Don't attempt to generate a LEAST when propogating multiple limits for the TOP
1 parent 2899189 commit 015dc3d

10 files changed

+222
-61
lines changed

src/EFCore.Jet/Query/Internal/JetQueryableMethodTranslatingExpressionVisitor.cs

Lines changed: 168 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System.Diagnostics.CodeAnalysis;
54
using EntityFrameworkCore.Jet.Internal;
5+
using Microsoft.EntityFrameworkCore.Query;
66
using Microsoft.EntityFrameworkCore.Query.SqlExpressions;
7+
using System.Diagnostics.CodeAnalysis;
78

89
namespace EntityFrameworkCore.Jet.Query.Internal;
910

@@ -15,6 +16,10 @@ namespace EntityFrameworkCore.Jet.Query.Internal;
1516
/// </summary>
1617
public class JetQueryableMethodTranslatingExpressionVisitor : RelationalQueryableMethodTranslatingExpressionVisitor
1718
{
19+
protected readonly RelationalQueryCompilationContext queryCompilationContext;
20+
21+
private readonly bool _subquery;
22+
1823
/// <summary>
1924
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
2025
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
@@ -27,6 +32,8 @@ public JetQueryableMethodTranslatingExpressionVisitor(
2732
RelationalQueryCompilationContext queryCompilationContext)
2833
: base(dependencies, relationalDependencies, queryCompilationContext)
2934
{
35+
this.queryCompilationContext = queryCompilationContext;
36+
_subquery = false;
3037
}
3138

3239
/// <summary>
@@ -39,6 +46,8 @@ protected JetQueryableMethodTranslatingExpressionVisitor(
3946
JetQueryableMethodTranslatingExpressionVisitor parentVisitor)
4047
: base(parentVisitor)
4148
{
49+
this.queryCompilationContext = parentVisitor.queryCompilationContext;
50+
_subquery = true;
4251
}
4352

4453
/// <summary>
@@ -140,9 +149,164 @@ protected override bool IsValidSelectExpressionForExecuteUpdate(
140149
return false;
141150
}
142151

143-
protected override ShapedQueryExpression? TranslateFirstOrDefault(ShapedQueryExpression source, LambdaExpression? predicate,
144-
Type returnType, bool returnDefault)
152+
protected override ShapedQueryExpression? TranslateElementAtOrDefault(
153+
ShapedQueryExpression source,
154+
Expression index,
155+
bool returnDefault)
156+
{
157+
var selectExpression = (SelectExpression)source.QueryExpression;
158+
var translation = TranslateExpression(index);
159+
if (translation == null)
160+
{
161+
return null;
162+
}
163+
164+
if (!IsOrdered(selectExpression))
165+
{
166+
queryCompilationContext.Logger.RowLimitingOperationWithoutOrderByWarning();
167+
}
168+
169+
selectExpression.ApplyOffset(translation);
170+
JetApplyLimit(selectExpression, TranslateExpression(Expression.Constant(1))!);
171+
172+
return source;
173+
}
174+
175+
protected override ShapedQueryExpression? TranslateFirstOrDefault(
176+
ShapedQueryExpression source,
177+
LambdaExpression? predicate,
178+
Type returnType,
179+
bool returnDefault)
180+
{
181+
if (predicate != null)
182+
{
183+
var translatedSource = TranslateWhere(source, predicate);
184+
if (translatedSource == null)
185+
{
186+
return null;
187+
}
188+
189+
source = translatedSource;
190+
}
191+
192+
var selectExpression = (SelectExpression)source.QueryExpression;
193+
if (selectExpression.Predicate == null
194+
&& selectExpression.Orderings.Count == 0)
195+
{
196+
queryCompilationContext.Logger.FirstWithoutOrderByAndFilterWarning();
197+
}
198+
199+
JetApplyLimit(selectExpression, TranslateExpression(Expression.Constant(1))!);
200+
201+
return source.ShaperExpression.Type != returnType
202+
? source.UpdateShaperExpression(Expression.Convert(source.ShaperExpression, returnType))
203+
: source;
204+
}
205+
206+
protected override ShapedQueryExpression? TranslateLastOrDefault(
207+
ShapedQueryExpression source,
208+
LambdaExpression? predicate,
209+
Type returnType,
210+
bool returnDefault)
211+
{
212+
var selectExpression = (SelectExpression)source.QueryExpression;
213+
if (selectExpression.Orderings.Count == 0)
214+
{
215+
throw new InvalidOperationException(
216+
RelationalStrings.LastUsedWithoutOrderBy(returnDefault ? nameof(Queryable.LastOrDefault) : nameof(Queryable.Last)));
217+
}
218+
219+
if (predicate != null)
220+
{
221+
var translatedSource = TranslateWhere(source, predicate);
222+
if (translatedSource == null)
223+
{
224+
return null;
225+
}
226+
227+
source = translatedSource;
228+
}
229+
230+
selectExpression.ReverseOrderings();
231+
JetApplyLimit(selectExpression, TranslateExpression(Expression.Constant(1))!);
232+
233+
return source.ShaperExpression.Type != returnType
234+
? source.UpdateShaperExpression(Expression.Convert(source.ShaperExpression, returnType))
235+
: source;
236+
}
237+
238+
protected override ShapedQueryExpression? TranslateSingleOrDefault(
239+
ShapedQueryExpression source,
240+
LambdaExpression? predicate,
241+
Type returnType,
242+
bool returnDefault)
145243
{
146-
return base.TranslateFirstOrDefault(source, predicate, returnType, returnDefault);
244+
if (predicate != null)
245+
{
246+
var translatedSource = TranslateWhere(source, predicate);
247+
if (translatedSource == null)
248+
{
249+
return null;
250+
}
251+
252+
source = translatedSource;
253+
}
254+
255+
var selectExpression = (SelectExpression)source.QueryExpression;
256+
JetApplyLimit(selectExpression, TranslateExpression(Expression.Constant(_subquery ? 1 : 2))!);
257+
258+
return source.ShaperExpression.Type != returnType
259+
? source.UpdateShaperExpression(Expression.Convert(source.ShaperExpression, returnType))
260+
: source;
147261
}
262+
263+
protected override ShapedQueryExpression? TranslateTake(ShapedQueryExpression source, Expression count)
264+
{
265+
var selectExpression = (SelectExpression)source.QueryExpression;
266+
var translation = TranslateExpression(count);
267+
if (translation == null)
268+
{
269+
return null;
270+
}
271+
272+
if (!IsOrdered(selectExpression))
273+
{
274+
queryCompilationContext.Logger.RowLimitingOperationWithoutOrderByWarning();
275+
}
276+
277+
JetApplyLimit(selectExpression, translation);
278+
279+
return source;
280+
}
281+
282+
private void JetApplyLimit(SelectExpression selectExpression, SqlExpression limit)
283+
{
284+
var oldLimit = selectExpression.Limit;
285+
286+
if (oldLimit is null)
287+
{
288+
selectExpression.SetLimit(limit);
289+
return;
290+
}
291+
292+
if (oldLimit is SqlConstantExpression { Value: int oldConst } && limit is SqlConstantExpression { Value: int newConst })
293+
{
294+
// if both the old and new limit are constants, use the smaller one
295+
// (aka constant-fold LEAST(constA, constB))
296+
if (oldConst > newConst)
297+
{
298+
selectExpression.SetLimit(limit);
299+
}
300+
301+
return;
302+
}
303+
304+
if (oldLimit.Equals(limit))
305+
{
306+
return;
307+
}
308+
309+
selectExpression.ApplyLimit(limit);
310+
}
311+
148312
}

test/EFCore.Jet.FunctionalTests/Query/NorthwindChangeTrackingQueryJetTest.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public override void Entity_range_does_not_revert_when_attached_dbSet()
110110
"""
111111
SELECT TOP 1 `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`
112112
FROM (
113-
SELECT TOP 2 `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`
113+
SELECT TOP @p `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`
114114
FROM `Customers` AS `c`
115115
ORDER BY `c`.`CustomerID`
116116
) AS `c0`
@@ -122,9 +122,9 @@ ORDER BY `c0`.`CustomerID`
122122
FROM (
123123
SELECT TOP 1 `c1`.`CustomerID`, `c1`.`Address`, `c1`.`City`, `c1`.`CompanyName`, `c1`.`ContactName`, `c1`.`ContactTitle`, `c1`.`Country`, `c1`.`Fax`, `c1`.`Phone`, `c1`.`PostalCode`, `c1`.`Region`
124124
FROM (
125-
SELECT TOP 2 `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`
125+
SELECT TOP @p0 + 1 `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`
126126
FROM (
127-
SELECT TOP 2 `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`
127+
SELECT TOP @p `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`
128128
FROM `Customers` AS `c`
129129
ORDER BY `c`.`CustomerID`
130130
) AS `c0`
@@ -136,7 +136,7 @@ ORDER BY `c2`.`CustomerID`
136136
""",
137137
//
138138
"""
139-
SELECT TOP 2 `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`
139+
SELECT TOP @p `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`
140140
FROM `Customers` AS `c`
141141
ORDER BY `c`.`CustomerID`
142142
""");
@@ -190,7 +190,7 @@ public override void Entity_range_does_not_revert_when_attached_dbContext()
190190
"""
191191
SELECT TOP 1 `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`
192192
FROM (
193-
SELECT TOP 2 `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`
193+
SELECT TOP @p `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`
194194
FROM `Customers` AS `c`
195195
ORDER BY `c`.`CustomerID`
196196
) AS `c0`
@@ -202,9 +202,9 @@ ORDER BY `c0`.`CustomerID`
202202
FROM (
203203
SELECT TOP 1 `c1`.`CustomerID`, `c1`.`Address`, `c1`.`City`, `c1`.`CompanyName`, `c1`.`ContactName`, `c1`.`ContactTitle`, `c1`.`Country`, `c1`.`Fax`, `c1`.`Phone`, `c1`.`PostalCode`, `c1`.`Region`
204204
FROM (
205-
SELECT TOP 2 `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`
205+
SELECT TOP @p0 + 1 `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`
206206
FROM (
207-
SELECT TOP 2 `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`
207+
SELECT TOP @p `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`
208208
FROM `Customers` AS `c`
209209
ORDER BY `c`.`CustomerID`
210210
) AS `c0`
@@ -216,7 +216,7 @@ ORDER BY `c2`.`CustomerID`
216216
""",
217217
//
218218
"""
219-
SELECT TOP 2 `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`
219+
SELECT TOP @p `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`
220220
FROM `Customers` AS `c`
221221
ORDER BY `c`.`CustomerID`
222222
""");

test/EFCore.Jet.FunctionalTests/Query/NorthwindEFPropertyIncludeQueryJetTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ public override async Task Multi_level_includes_are_applied_with_take(bool async
794794
FROM (
795795
SELECT TOP 1 `c0`.`CustomerID`
796796
FROM (
797-
SELECT TOP 1 `c`.`CustomerID`
797+
SELECT TOP @p `c`.`CustomerID`
798798
FROM `Customers` AS `c`
799799
WHERE `c`.`CustomerID` LIKE 'A%'
800800
ORDER BY `c`.`CustomerID`
@@ -969,9 +969,9 @@ public override async Task Multi_level_includes_are_applied_with_skip_take(bool
969969
FROM (
970970
SELECT TOP 1 `c0`.`CustomerID`
971971
FROM (
972-
SELECT TOP 1 `c1`.`CustomerID`
972+
SELECT TOP @p `c1`.`CustomerID`
973973
FROM (
974-
SELECT TOP 2 `c`.`CustomerID`
974+
SELECT TOP @p + @p `c`.`CustomerID`
975975
FROM `Customers` AS `c`
976976
WHERE `c`.`CustomerID` LIKE 'A%'
977977
ORDER BY `c`.`CustomerID`

test/EFCore.Jet.FunctionalTests/Query/NorthwindIncludeNoTrackingQueryJetTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ public override async Task Multi_level_includes_are_applied_with_take(bool async
793793
FROM (
794794
SELECT TOP 1 `c0`.`CustomerID`
795795
FROM (
796-
SELECT TOP 1 `c`.`CustomerID`
796+
SELECT TOP @p `c`.`CustomerID`
797797
FROM `Customers` AS `c`
798798
WHERE `c`.`CustomerID` LIKE 'A%'
799799
ORDER BY `c`.`CustomerID`
@@ -1374,9 +1374,9 @@ public override async Task Multi_level_includes_are_applied_with_skip_take(bool
13741374
FROM (
13751375
SELECT TOP 1 `c0`.`CustomerID`
13761376
FROM (
1377-
SELECT TOP 1 `c1`.`CustomerID`
1377+
SELECT TOP @p `c1`.`CustomerID`
13781378
FROM (
1379-
SELECT TOP 2 `c`.`CustomerID`
1379+
SELECT TOP @p + @p `c`.`CustomerID`
13801380
FROM `Customers` AS `c`
13811381
WHERE `c`.`CustomerID` LIKE 'A%'
13821382
ORDER BY `c`.`CustomerID`

test/EFCore.Jet.FunctionalTests/Query/NorthwindIncludeQueryJetTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,7 +1686,7 @@ public override async Task Multi_level_includes_are_applied_with_take(bool async
16861686
FROM (
16871687
SELECT TOP 1 `c0`.`CustomerID`
16881688
FROM (
1689-
SELECT TOP 1 `c`.`CustomerID`
1689+
SELECT TOP @p `c`.`CustomerID`
16901690
FROM `Customers` AS `c`
16911691
WHERE `c`.`CustomerID` LIKE 'A%'
16921692
ORDER BY `c`.`CustomerID`
@@ -1712,9 +1712,9 @@ public override async Task Multi_level_includes_are_applied_with_skip_take(bool
17121712
FROM (
17131713
SELECT TOP 1 `c0`.`CustomerID`
17141714
FROM (
1715-
SELECT TOP 1 `c1`.`CustomerID`
1715+
SELECT TOP @p `c1`.`CustomerID`
17161716
FROM (
1717-
SELECT TOP 2 `c`.`CustomerID`
1717+
SELECT TOP @p + @p `c`.`CustomerID`
17181718
FROM `Customers` AS `c`
17191719
WHERE `c`.`CustomerID` LIKE 'A%'
17201720
ORDER BY `c`.`CustomerID`

test/EFCore.Jet.FunctionalTests/Query/NorthwindMiscellaneousQueryJetTest.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,7 +2167,7 @@ public override async Task Take_with_single(bool isAsync)
21672167
"""
21682168
SELECT TOP 2 `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`
21692169
FROM (
2170-
SELECT TOP 1 `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`
2170+
SELECT TOP @p `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`
21712171
FROM `Customers` AS `c`
21722172
ORDER BY `c`.`CustomerID`
21732173
) AS `c0`
@@ -2183,7 +2183,7 @@ public override async Task Take_with_single_select_many(bool isAsync)
21832183
"""
21842184
SELECT TOP 2 `s`.`CustomerID`, `s`.`Address`, `s`.`City`, `s`.`CompanyName`, `s`.`ContactName`, `s`.`ContactTitle`, `s`.`Country`, `s`.`Fax`, `s`.`Phone`, `s`.`PostalCode`, `s`.`Region`, `s`.`OrderID`, `s`.`CustomerID0`, `s`.`EmployeeID`, `s`.`OrderDate`
21852185
FROM (
2186-
SELECT TOP 1 `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `o`.`OrderID`, `o`.`CustomerID` AS `CustomerID0`, `o`.`EmployeeID`, `o`.`OrderDate`
2186+
SELECT TOP @p `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`, `o`.`OrderID`, `o`.`CustomerID` AS `CustomerID0`, `o`.`EmployeeID`, `o`.`OrderDate`
21872187
FROM `Customers` AS `c`,
21882188
`Orders` AS `o`
21892189
ORDER BY `c`.`CustomerID`, `o`.`OrderID`
@@ -3635,11 +3635,11 @@ public override async Task OrderBy_skip_take_take(bool isAsync)
36353635

36363636
AssertSql(
36373637
"""
3638-
SELECT TOP 3 `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`
3638+
SELECT TOP @p1 `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`
36393639
FROM (
3640-
SELECT TOP 8 `c1`.`CustomerID`, `c1`.`Address`, `c1`.`City`, `c1`.`CompanyName`, `c1`.`ContactName`, `c1`.`ContactTitle`, `c1`.`Country`, `c1`.`Fax`, `c1`.`Phone`, `c1`.`PostalCode`, `c1`.`Region`
3640+
SELECT TOP @p0 `c1`.`CustomerID`, `c1`.`Address`, `c1`.`City`, `c1`.`CompanyName`, `c1`.`ContactName`, `c1`.`ContactTitle`, `c1`.`Country`, `c1`.`Fax`, `c1`.`Phone`, `c1`.`PostalCode`, `c1`.`Region`
36413641
FROM (
3642-
SELECT TOP 13 `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`
3642+
SELECT TOP @p + @p0 `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`
36433643
FROM `Customers` AS `c`
36443644
ORDER BY `c`.`ContactTitle`, `c`.`ContactName`
36453645
) AS `c1`
@@ -3655,15 +3655,15 @@ public override async Task OrderBy_skip_take_take_take_take(bool isAsync)
36553655

36563656
AssertSql(
36573657
"""
3658-
SELECT TOP 5 `c2`.`CustomerID`, `c2`.`Address`, `c2`.`City`, `c2`.`CompanyName`, `c2`.`ContactName`, `c2`.`ContactTitle`, `c2`.`Country`, `c2`.`Fax`, `c2`.`Phone`, `c2`.`PostalCode`, `c2`.`Region`
3658+
SELECT TOP @p `c2`.`CustomerID`, `c2`.`Address`, `c2`.`City`, `c2`.`CompanyName`, `c2`.`ContactName`, `c2`.`ContactTitle`, `c2`.`Country`, `c2`.`Fax`, `c2`.`Phone`, `c2`.`PostalCode`, `c2`.`Region`
36593659
FROM (
3660-
SELECT TOP 8 `c1`.`CustomerID`, `c1`.`Address`, `c1`.`City`, `c1`.`CompanyName`, `c1`.`ContactName`, `c1`.`ContactTitle`, `c1`.`Country`, `c1`.`Fax`, `c1`.`Phone`, `c1`.`PostalCode`, `c1`.`Region`
3660+
SELECT TOP @p2 `c1`.`CustomerID`, `c1`.`Address`, `c1`.`City`, `c1`.`CompanyName`, `c1`.`ContactName`, `c1`.`ContactTitle`, `c1`.`Country`, `c1`.`Fax`, `c1`.`Phone`, `c1`.`PostalCode`, `c1`.`Region`
36613661
FROM (
3662-
SELECT TOP 10 `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`
3662+
SELECT TOP @p1 `c0`.`CustomerID`, `c0`.`Address`, `c0`.`City`, `c0`.`CompanyName`, `c0`.`ContactName`, `c0`.`ContactTitle`, `c0`.`Country`, `c0`.`Fax`, `c0`.`Phone`, `c0`.`PostalCode`, `c0`.`Region`
36633663
FROM (
3664-
SELECT TOP 15 `c3`.`CustomerID`, `c3`.`Address`, `c3`.`City`, `c3`.`CompanyName`, `c3`.`ContactName`, `c3`.`ContactTitle`, `c3`.`Country`, `c3`.`Fax`, `c3`.`Phone`, `c3`.`PostalCode`, `c3`.`Region`
3664+
SELECT TOP @p0 `c3`.`CustomerID`, `c3`.`Address`, `c3`.`City`, `c3`.`CompanyName`, `c3`.`ContactName`, `c3`.`ContactTitle`, `c3`.`Country`, `c3`.`Fax`, `c3`.`Phone`, `c3`.`PostalCode`, `c3`.`Region`
36653665
FROM (
3666-
SELECT TOP 20 `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`
3666+
SELECT TOP @p + @p0 `c`.`CustomerID`, `c`.`Address`, `c`.`City`, `c`.`CompanyName`, `c`.`ContactName`, `c`.`ContactTitle`, `c`.`Country`, `c`.`Fax`, `c`.`Phone`, `c`.`PostalCode`, `c`.`Region`
36673667
FROM `Customers` AS `c`
36683668
ORDER BY `c`.`ContactTitle`, `c`.`ContactName`
36693669
) AS `c3`

0 commit comments

Comments
 (0)