-
-
Notifications
You must be signed in to change notification settings - Fork 453
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for Select() + paging in LINQ. Closes GH-3337
- Loading branch information
1 parent
ab8ac50
commit 537d0ba
Showing
2 changed files
with
54 additions
and
1 deletion.
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,47 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Marten; | ||
using Marten.Pagination; | ||
using Marten.Testing.Documents; | ||
using Marten.Testing.Harness; | ||
using Shouldly; | ||
using Xunit.Abstractions; | ||
|
||
namespace LinqTests.Bugs; | ||
|
||
public class Bug_3337_select_page : BugIntegrationContext | ||
{ | ||
private readonly ITestOutputHelper _output; | ||
|
||
public Bug_3337_select_page(ITestOutputHelper output) | ||
{ | ||
_output = output; | ||
} | ||
|
||
[Fact] | ||
public async Task try_it_out() | ||
{ | ||
await theStore.BulkInsertAsync(Target.GenerateRandomData(1000).ToArray()); | ||
|
||
theSession.Logger = new TestOutputMartenLogger(_output); | ||
var results = await theSession.Query<Target>().Where(x => x.Inner != null) | ||
.Select(x => new SelectedGuy() { Id = x.Id, Number = x.Inner.Number, Text = x.String }) | ||
.Take(5).Stats(out var statistics).ToListAsync(); | ||
//.ToPagedListAsync(1, 5); | ||
|
||
foreach (var result in results) | ||
{ | ||
result.Number.ShouldNotBe(0); | ||
result.Id.ShouldNotBe(Guid.Empty); | ||
result.Text.ShouldNotBeNull(); | ||
} | ||
} | ||
} | ||
|
||
public class SelectedGuy | ||
{ | ||
public int Number { get; set; } | ||
public Guid Id { get; set; } | ||
public string Text { get; set; } | ||
} |
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