From 377bb088da9d37bb73ab61de998d550cf7d7abf8 Mon Sep 17 00:00:00 2001 From: "Jeremy D. Miller" Date: Sun, 4 Aug 2024 15:48:39 -0500 Subject: [PATCH] Test to verify that deep nested accessors work in Select() functions. Closes GH-3350 --- .../Bug_3350_Select_with_deep_accessor.cs | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/LinqTests/Bugs/Bug_3350_Select_with_deep_accessor.cs diff --git a/src/LinqTests/Bugs/Bug_3350_Select_with_deep_accessor.cs b/src/LinqTests/Bugs/Bug_3350_Select_with_deep_accessor.cs new file mode 100644 index 0000000000..2e43d241fe --- /dev/null +++ b/src/LinqTests/Bugs/Bug_3350_Select_with_deep_accessor.cs @@ -0,0 +1,35 @@ +using System.Linq; +using System.Threading.Tasks; +using Marten; +using Marten.Testing.Documents; +using Marten.Testing.Harness; +using Shouldly; + +namespace LinqTests.Bugs; + +public class Bug_3350_Select_with_deep_accessor : BugIntegrationContext +{ + [Fact] + public async Task get_the_deeply_nested_value_in_select() + { + await theStore.BulkInsertAsync(Target.GenerateRandomData(1000).ToArray()); + + var views = await theSession.Query() + .Where(x => x.Inner != null && x.Inner.String != null) + .Select(x => new SelectedView { Number = x.Number, Text = x.Inner.String }).ToListAsync(); + + views.ShouldNotBeEmpty(); + + foreach (var view in views) + { + view.Text.ShouldNotBeNullOrEmpty(); + } + + } +} + +public class SelectedView +{ + public string Text { get; set; } + public int Number { get; set; } +}