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() { 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() {