diff --git a/FreeSql.Tests/FreeSql.Tests/PostgreSQL/Curd/PostgreSQLSelectTest.cs b/FreeSql.Tests/FreeSql.Tests/PostgreSQL/Curd/PostgreSQLSelectTest.cs index 83ac07ec..8f0549d2 100644 --- a/FreeSql.Tests/FreeSql.Tests/PostgreSQL/Curd/PostgreSQLSelectTest.cs +++ b/FreeSql.Tests/FreeSql.Tests/PostgreSQL/Curd/PostgreSQLSelectTest.cs @@ -266,6 +266,11 @@ WHERE (((a.""name"") in (SELECT s.""title"" as1 public int id { get; set; } public string name { get; set; } //这是join表的属性 public int ParentId { get; set; } //这是join表的属性 + + public bool? testBool1 { get; set; } + public bool? testBool2 { get; set; } + public bool testBool3 { get; set; } + public bool testBool4 { get; set; } } class TestDto2 { @@ -283,8 +288,11 @@ WHERE (((a.""name"") in (SELECT s.""title"" as1 [Fact] public void ToList() { - - var testDto1 = select.Limit(10).ToList(a => new TestDto { id = a.Id, name = a.Title }); + var testDto1 = select.Limit(10).ToList(a => new TestDto { id = a.Id, name = a.Title, testBool1 = false, testBool2 = true, testBool3 = false, testBool4 = true }); + Assert.False(testDto1[0].testBool1); + Assert.True(testDto1[0].testBool2); + Assert.False(testDto1[0].testBool3); + Assert.True(testDto1[0].testBool4); var testDto2 = select.Limit(10).ToList(a => new TestDto()); var testDto3 = select.Limit(10).ToList(a => new TestDto { }); var testDto4 = select.Limit(10).ToList(a => new TestDto() { }); diff --git a/FreeSql.Tests/FreeSql.Tests/Sqlite/Curd/SqliteSelectTest.cs b/FreeSql.Tests/FreeSql.Tests/Sqlite/Curd/SqliteSelectTest.cs index d6e54852..3285c885 100644 --- a/FreeSql.Tests/FreeSql.Tests/Sqlite/Curd/SqliteSelectTest.cs +++ b/FreeSql.Tests/FreeSql.Tests/Sqlite/Curd/SqliteSelectTest.cs @@ -281,6 +281,8 @@ WHERE (((a.""Name"") in (SELECT s.""Title"" as1 public bool? testBool1 { get; set; } public bool? testBool2 { get; set; } + public bool testBool3 { get; set; } + public bool testBool4 { get; set; } public TestDtoLeftJoin Obj { get; set; } } @@ -346,7 +348,11 @@ WHERE (((a.""Name"") in (SELECT s.""Title"" as1 } select.Limit(10).ToList(a => new TestDto { id = a.Id, name = a.Title }); - var testDto1 = select.Limit(10).ToList(a => new TestDto { id = a.Id, name = a.Title }); + var testDto1 = select.Limit(10).ToList(a => new TestDto { id = a.Id, name = a.Title, testBool1 = false, testBool2 = true, testBool3 = false, testBool4 = true }); + Assert.False(testDto1[0].testBool1); + Assert.True(testDto1[0].testBool2); + Assert.False(testDto1[0].testBool3); + Assert.True(testDto1[0].testBool4); var testDto2 = select.Limit(10).ToList(a => new TestDto()); var testDto3 = select.Limit(10).ToList(a => new TestDto { }); var testDto4 = select.Limit(10).ToList(a => new TestDto() { }); diff --git a/FreeSql/Internal/UtilsExpressionTree.cs b/FreeSql/Internal/UtilsExpressionTree.cs index 23250bb1..bd341b7e 100644 --- a/FreeSql/Internal/UtilsExpressionTree.cs +++ b/FreeSql/Internal/UtilsExpressionTree.cs @@ -2298,7 +2298,9 @@ namespace FreeSql.Internal Expression.Equal(Expression.Convert(valueExp, typeof(string)), Expression.Constant("False")), Expression.OrElse( Expression.Equal(Expression.Convert(valueExp, typeof(string)), Expression.Constant("false")), - Expression.Equal(Expression.Convert(valueExp, typeof(string)), Expression.Constant("0"))))), + Expression.OrElse( + Expression.Equal(Expression.Convert(valueExp, typeof(string)), Expression.Constant("f")), + Expression.Equal(Expression.Convert(valueExp, typeof(string)), Expression.Constant("0")))))), typeof(object)) ); break;