@@ -19,8 +19,8 @@ public class Parser<T> where T : class
19
19
private int _take ;
20
20
private int _skip ;
21
21
private bool _sortDisabled = false ;
22
- private string _startsWithtoken = "*|" ;
23
- private string _endsWithToken = "|*" ;
22
+ private string _startsWithtoken = Constants . DEFAULT_STARTS_WITH_TOKEN ;
23
+ private string _endsWithToken = Constants . DEFAULT_ENDS_WITH_TOKEN ;
24
24
private bool _isEnumerableQuery ;
25
25
26
26
private Dictionary < string , Expression > _converters = new Dictionary < string , Expression > ( ) ;
@@ -282,6 +282,23 @@ private string GetFilterFn(string filter)
282
282
}
283
283
}
284
284
285
+ private string RemoveFilterTokens ( string filter )
286
+ {
287
+ string untoken = filter ;
288
+
289
+ if ( untoken . StartsWith ( _startsWithtoken ) )
290
+ {
291
+ untoken = untoken . Remove ( 0 , _startsWithtoken . Length ) ;
292
+ }
293
+
294
+ if ( untoken . EndsWith ( _endsWithToken ) )
295
+ {
296
+ untoken = untoken . Remove ( filter . LastIndexOf ( _endsWithToken ) , _endsWithToken . Length ) ;
297
+ }
298
+
299
+ return untoken ;
300
+ }
301
+
285
302
/// <summary>
286
303
/// Generate a lamda expression based on a search filter for all mapped columns
287
304
/// </summary>
@@ -297,6 +314,7 @@ private Expression<Func<T, bool>> GenerateEntityFilter()
297
314
if ( ! string . IsNullOrWhiteSpace ( filter ) )
298
315
{
299
316
globalFilterFn = GetFilterFn ( filter ) ;
317
+ filter = RemoveFilterTokens ( filter ) ;
300
318
globalFilterConst = Expression . Constant ( filter . ToLower ( ) ) ;
301
319
}
302
320
@@ -318,7 +336,8 @@ private Expression<Func<T, bool>> GenerateEntityFilter()
318
336
ConstantExpression individualFilterConst = null ;
319
337
if ( ! string . IsNullOrWhiteSpace ( propMap . Value . Filter ) )
320
338
{
321
- propFilterFn = GetFilterFn ( propMap . Value . Filter ) ;
339
+ propFilterFn = GetFilterFn ( propMap . Value . Filter ) ;
340
+ propMap . Value . Filter = RemoveFilterTokens ( propMap . Value . Filter ) ;
322
341
individualFilterConst = Expression . Constant ( propMap . Value . Filter . ToLower ( ) ) ;
323
342
}
324
343
@@ -440,6 +459,9 @@ public class Constants
440
459
public const string STARTS_WITH_FN = "StartsWith" ;
441
460
public const string ENDS_WITH_FN = "EndsWith" ;
442
461
462
+ public const string DEFAULT_STARTS_WITH_TOKEN = "*|" ;
463
+ public const string DEFAULT_ENDS_WITH_TOKEN = "|*" ;
464
+
443
465
public static string GetKey ( string format , string index )
444
466
{
445
467
return String . Format ( format , index ) ;
0 commit comments