@@ -19,8 +19,8 @@ public class Parser<T> where T : class
1919 private int _take ;
2020 private int _skip ;
2121 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 ;
2424 private bool _isEnumerableQuery ;
2525
2626 private Dictionary < string , Expression > _converters = new Dictionary < string , Expression > ( ) ;
@@ -282,6 +282,23 @@ private string GetFilterFn(string filter)
282282 }
283283 }
284284
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+
285302 /// <summary>
286303 /// Generate a lamda expression based on a search filter for all mapped columns
287304 /// </summary>
@@ -297,6 +314,7 @@ private Expression<Func<T, bool>> GenerateEntityFilter()
297314 if ( ! string . IsNullOrWhiteSpace ( filter ) )
298315 {
299316 globalFilterFn = GetFilterFn ( filter ) ;
317+ filter = RemoveFilterTokens ( filter ) ;
300318 globalFilterConst = Expression . Constant ( filter . ToLower ( ) ) ;
301319 }
302320
@@ -318,7 +336,8 @@ private Expression<Func<T, bool>> GenerateEntityFilter()
318336 ConstantExpression individualFilterConst = null ;
319337 if ( ! string . IsNullOrWhiteSpace ( propMap . Value . Filter ) )
320338 {
321- propFilterFn = GetFilterFn ( propMap . Value . Filter ) ;
339+ propFilterFn = GetFilterFn ( propMap . Value . Filter ) ;
340+ propMap . Value . Filter = RemoveFilterTokens ( propMap . Value . Filter ) ;
322341 individualFilterConst = Expression . Constant ( propMap . Value . Filter . ToLower ( ) ) ;
323342 }
324343
@@ -440,6 +459,9 @@ public class Constants
440459 public const string STARTS_WITH_FN = "StartsWith" ;
441460 public const string ENDS_WITH_FN = "EndsWith" ;
442461
462+ public const string DEFAULT_STARTS_WITH_TOKEN = "*|" ;
463+ public const string DEFAULT_ENDS_WITH_TOKEN = "|*" ;
464+
443465 public static string GetKey ( string format , string index )
444466 {
445467 return String . Format ( format , index ) ;
0 commit comments