-
-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test to verify that Include() plus ToPagedList() works after the LINQ…
… overhaul. Closes GH-2553
- Loading branch information
1 parent
02815f7
commit 67d5b7d
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Marten.Pagination; | ||
using Marten.Testing.Harness; | ||
using Shouldly; | ||
|
||
namespace LinqTests.Bugs; | ||
|
||
public class Bug_2553_Include_with_ToPagedList: BugIntegrationContext | ||
{ | ||
public record Foo(Guid Id); | ||
|
||
public record Bar(Guid Id, Guid FooId); | ||
|
||
[Fact] | ||
public void query_should_return_included_docs() | ||
{ | ||
var foos = Enumerable.Range(start: 0, count: 100).Select(i => new Foo(Guid.NewGuid())).ToArray(); | ||
var bars = Enumerable.Range(start: 0, count: 100).Select(i => new Bar(Guid.NewGuid(), FooId: foos[i].Id)); | ||
|
||
foreach (var foo in foos) | ||
{ | ||
theSession.Store(foo); | ||
} | ||
|
||
foreach (var bar in bars) | ||
{ | ||
theSession.Store(bar); | ||
} | ||
|
||
theSession.SaveChanges(); | ||
|
||
var includedFoos = new Dictionary<Guid, Foo>(); | ||
|
||
var queriedBars = theSession.Query<Bar>() | ||
.Include(bar => bar.FooId, dictionary: includedFoos) | ||
.ToPagedList(pageNumber: 1, pageSize: 4); | ||
|
||
foreach (var queriedBar in queriedBars) | ||
{ | ||
includedFoos.ShouldContainKey(key: queriedBar.FooId); | ||
} | ||
} | ||
} |