@@ -18,6 +18,8 @@ public class Waybill
1818 public string VirtProperty => "WaybillVirtPropertyValue" ;
1919
2020 public string VirtProperty2 => "WaybillVirtPropertyValue2" ;
21+
22+ public bool BoolVirtProperty => false ;
2123 }
2224
2325 public class CustomSqlServerDialectProvider : SqliteOrmLiteDialectProvider
@@ -43,6 +45,8 @@ protected override Object GetMemberExpression(MemberExpression m)
4345 return "WaybillVirtPropertyValue" ;
4446 if ( m . Member . Name == nameof ( Waybill . VirtProperty2 ) )
4547 return "WaybillVirtPropertyValue2" ;
48+ if ( m . Member . Name == nameof ( Waybill . BoolVirtProperty ) )
49+ return false ;
4650 }
4751
4852 return base . GetMemberExpression ( m ) ;
@@ -153,5 +157,63 @@ public void Can_Where_using_constant_filter8()
153157 var target = Db . Select ( q ) ;
154158 Assert . AreEqual ( 0 , target . Count ) ;
155159 }
160+
161+ [ Test ]
162+ public void Can_Where_using_constant_filter9 ( )
163+ {
164+ System . Linq . Expressions . Expression < Func < Waybill , bool > > filter = x => x . BoolVirtProperty ;
165+ var q = Db . From < Waybill > ( ) . Where ( filter ) ;
166+ var target = Db . Select ( q ) ;
167+ Assert . AreEqual ( 0 , target . Count ) ;
168+ }
169+
170+ [ Test ]
171+ public void Can_Where_using_constant_filter10 ( )
172+ {
173+ System . Linq . Expressions . Expression < Func < Waybill , bool > > filter = x => ! x . BoolVirtProperty ;
174+ var q = Db . From < Waybill > ( ) . Where ( filter ) ;
175+ var target = Db . Select ( q ) ;
176+ Assert . AreEqual ( 3 , target . Count ) ;
177+ }
178+
179+ [ Test ]
180+ public void Can_Where_using_constant_filter11 ( )
181+ {
182+ System . Linq . Expressions . Expression < Func < Waybill , bool > > filter = x => x . BoolVirtProperty && x . VirtProperty == "WaybillVirtPropertyValue" ;
183+ var q = Db . From < Waybill > ( ) . Where ( filter ) ;
184+ var target = Db . Select ( q ) ;
185+ Assert . AreEqual ( 0 , target . Count ) ;
186+ }
187+
188+ [ Test ]
189+ public void Can_Where_using_constant_filter12 ( )
190+ {
191+ System . Linq . Expressions . Expression < Func < Waybill , bool > > filter = x => ! x . BoolVirtProperty || x . VirtProperty == "WaybillVirtPropertyValue" ;
192+ var q = Db . From < Waybill > ( ) . Where ( filter ) ;
193+ var target = Db . Select ( q ) ;
194+ Assert . AreEqual ( 3 , target . Count ) ;
195+ }
196+
197+ [ Test ]
198+ public void Can_Where_using_constant_filter13 ( )
199+ {
200+ System . Linq . Expressions . Expression < Func < Waybill , bool > > filter = x => ! x . BoolVirtProperty &&
201+ x . VirtProperty == "WaybillVirtPropertyValue" &&
202+ x . Number == 100 ;
203+ var q = Db . From < Waybill > ( ) . Where ( filter ) ;
204+ var target = Db . Select ( q ) ;
205+ Assert . AreEqual ( 1 , target . Count ) ;
206+ }
207+
208+ [ Test ]
209+ public void Can_Where_using_constant_filter14 ( )
210+ {
211+ System . Linq . Expressions . Expression < Func < Waybill , bool > > filter = x => x . Number == 100 &&
212+ ( x . BoolVirtProperty ||
213+ x . VirtProperty == "WaybillVirtPropertyValue" ) ;
214+ var q = Db . From < Waybill > ( ) . Where ( filter ) ;
215+ var target = Db . Select ( q ) ;
216+ Assert . AreEqual ( 1 , target . Count ) ;
217+ }
156218 }
157219}
0 commit comments