Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 2ba049c

Browse files
committed
Merge pull request #176 from rossipedia/nullable-issue
Failing test for nullable parameters
2 parents b50df53 + 81b3c3a commit 2ba049c

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/ServiceStack.OrmLite.SqlServerTests/SqlServerExpressionVisitorQueryTest.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,31 @@ public void test_if_ev_still_works_without_limit_and_orderby()
9898
Assert.IsTrue(result.Count > 0);
9999
}
100100
}
101+
102+
[Test]
103+
public void test_if_and_works_with_nullable_parameter()
104+
{
105+
using(var db = ConnectionString.OpenDbConnection())
106+
{
107+
db.CreateTable<TestEntity>(true);
108+
db.Insert(new TestEntity
109+
{
110+
Id = 2000,
111+
Foo = this.RandomString(16),
112+
Bar = this.RandomString(16),
113+
Baz = this.RandomDecimal()
114+
});
115+
116+
var ev = OrmLiteConfig.DialectProvider.ExpressionVisitor<TestEntity>();
117+
ev.Where(e => e.Id == 2000);
118+
int? i = null;
119+
ev.And(e => e.NullInt == i);
120+
121+
var result = db.Select(ev);
122+
Assert.NotNull(result);
123+
Assert.IsTrue(result.Count > 0);
124+
}
125+
}
101126

102127
protected void FillTestEntityTableWithTestData(IDbConnection db)
103128
{

src/ServiceStack.OrmLite.SqlServerTests/UseCase/TestEntity.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public class TestEntity
1515

1616
public String Foo { get; set; }
1717
public String Bar { get; set; }
18+
public int? NullInt { get; set; }
19+
1820
[Index]
1921
public Decimal Baz { get; set; }
2022

0 commit comments

Comments
 (0)