Skip to content

Commit cfe9698

Browse files
committed
Add a suggested test for checking Linq order by behavior.
1 parent bec685e commit cfe9698

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

src/NHibernate.Test/Async/Linq/PagingTests.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,28 @@ public async Task PagedProductsWithOuterWhereClauseAsync()
260260
Assert.That(ids, Is.EqualTo(inMemoryIds));
261261
}
262262

263+
[Test]
264+
public async Task PagedProductsWithOuterWhereClause2Async()
265+
{
266+
if (Dialect is MySQLDialect)
267+
Assert.Ignore("MySQL does not support LIMIT in subqueries.");
268+
269+
//NH-2588
270+
var inMemoryIds = (await (db.Products.ToListAsync()))
271+
.OrderBy(x => x.UnitPrice).ThenBy(x => x.ProductId)
272+
.Skip(10).Take(20)
273+
.Where(x => x.UnitsInStock > 0)
274+
.ToList();
275+
276+
var ids = await (db.Products
277+
.OrderBy(x => x.UnitPrice).ThenBy(x => x.ProductId)
278+
.Skip(10).Take(20)
279+
.Where(x => x.UnitsInStock > 0)
280+
.ToListAsync());
281+
282+
Assert.That(ids, Is.EqualTo(inMemoryIds));
283+
}
284+
263285
[Test]
264286
public async Task PagedProductsWithOuterWhereClauseResortAsync()
265287
{

src/NHibernate.Test/Linq/PagingTests.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,28 @@ public void PagedProductsWithOuterWhereClause()
386386
Assert.That(ids, Is.EqualTo(inMemoryIds));
387387
}
388388

389+
[Test]
390+
public void PagedProductsWithOuterWhereClause2()
391+
{
392+
if (Dialect is MySQLDialect)
393+
Assert.Ignore("MySQL does not support LIMIT in subqueries.");
394+
395+
//NH-2588
396+
var inMemoryIds = db.Products.ToList()
397+
.OrderBy(x => x.UnitPrice).ThenBy(x => x.ProductId)
398+
.Skip(10).Take(20)
399+
.Where(x => x.UnitsInStock > 0)
400+
.ToList();
401+
402+
var ids = db.Products
403+
.OrderBy(x => x.UnitPrice).ThenBy(x => x.ProductId)
404+
.Skip(10).Take(20)
405+
.Where(x => x.UnitsInStock > 0)
406+
.ToList();
407+
408+
Assert.That(ids, Is.EqualTo(inMemoryIds));
409+
}
410+
389411
[Test]
390412
public void PagedProductsWithOuterWhereClauseResort()
391413
{

0 commit comments

Comments
 (0)