@@ -18,6 +18,8 @@ public class Waybill
18
18
public string VirtProperty => "WaybillVirtPropertyValue" ;
19
19
20
20
public string VirtProperty2 => "WaybillVirtPropertyValue2" ;
21
+
22
+ public bool BoolVirtProperty => false ;
21
23
}
22
24
23
25
public class CustomSqlServerDialectProvider : SqliteOrmLiteDialectProvider
@@ -43,6 +45,8 @@ protected override Object GetMemberExpression(MemberExpression m)
43
45
return "WaybillVirtPropertyValue" ;
44
46
if ( m . Member . Name == nameof ( Waybill . VirtProperty2 ) )
45
47
return "WaybillVirtPropertyValue2" ;
48
+ if ( m . Member . Name == nameof ( Waybill . BoolVirtProperty ) )
49
+ return false ;
46
50
}
47
51
48
52
return base . GetMemberExpression ( m ) ;
@@ -153,5 +157,63 @@ public void Can_Where_using_constant_filter8()
153
157
var target = Db . Select ( q ) ;
154
158
Assert . AreEqual ( 0 , target . Count ) ;
155
159
}
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
+ }
156
218
}
157
219
}
0 commit comments