From 6e65bc13a015f1e74ab475389b20cc38faf147d5 Mon Sep 17 00:00:00 2001 From: Krzysztof Kowal Date: Mon, 12 Sep 2022 13:10:53 +0200 Subject: [PATCH 1/2] LINQ Nullable in WHERE condition tests --- src/NHibernate.Test/Linq/WhereTests.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/NHibernate.Test/Linq/WhereTests.cs b/src/NHibernate.Test/Linq/WhereTests.cs index 02dc58b34b7..ab02e486761 100644 --- a/src/NHibernate.Test/Linq/WhereTests.cs +++ b/src/NHibernate.Test/Linq/WhereTests.cs @@ -738,6 +738,28 @@ from o in session.Query() Assert.That(query.Count, Is.EqualTo(3)); } + [Test(Description = "GH-3156")] + public void CanUseNullableWithoutAValue() + { + bool? isActive = null; + + Assert.DoesNotThrow( + () => _ = session.Query() + .Where(r => !isActive.HasValue || r.IsActive == isActive.Value) + .ToList()); + } + + [Test(Description = "GH-3156")] + public void CanUseNullableWithoutAValue2() + { + bool? isActive = null; + + Assert.DoesNotThrow( + () => _ = session.Query() + .Where(r => isActive == null || r.IsActive == isActive.Value) + .ToList()); + } + [Test(Description = "NH-2375")] public void OfTypeWithWhereAndProjection() { From e47c3a6a83bc110662a9293f7d1a53d7e4c82dd5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 12 Sep 2022 11:14:26 +0000 Subject: [PATCH 2/2] Generate async files --- src/NHibernate.Test/Async/Linq/WhereTests.cs | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/NHibernate.Test/Async/Linq/WhereTests.cs b/src/NHibernate.Test/Async/Linq/WhereTests.cs index 56d183e49c9..35cafb1eb7b 100644 --- a/src/NHibernate.Test/Async/Linq/WhereTests.cs +++ b/src/NHibernate.Test/Async/Linq/WhereTests.cs @@ -737,6 +737,28 @@ from o in session.Query() Assert.That(query.Count, Is.EqualTo(3)); } + [Test(Description = "GH-3156")] + public void CanUseNullableWithoutAValueAsync() + { + bool? isActive = null; + + Assert.DoesNotThrowAsync( + async () => _ = await (session.Query() + .Where(r => !isActive.HasValue || r.IsActive == isActive.Value) + .ToListAsync())); + } + + [Test(Description = "GH-3156")] + public void CanUseNullableWithoutAValue2Async() + { + bool? isActive = null; + + Assert.DoesNotThrowAsync( + async () => _ = await (session.Query() + .Where(r => isActive == null || r.IsActive == isActive.Value) + .ToListAsync())); + } + [Test(Description = "NH-2375")] public async Task OfTypeWithWhereAndProjectionAsync() {