@@ -21,10 +21,18 @@ public class Parser<T> where T : class
2121 private bool _sortDisabled = false ;
2222
2323
24- private Type [ ] _translatable =
24+ private Type [ ] _convertable =
2525 {
26- typeof ( string )
27-
26+ typeof ( int ) ,
27+ typeof ( Nullable < int > ) ,
28+ typeof ( decimal ) ,
29+ typeof ( Nullable < decimal > ) ,
30+ typeof ( float ) ,
31+ typeof ( Nullable < float > ) ,
32+ typeof ( double ) ,
33+ typeof ( Nullable < double > ) ,
34+ typeof ( DateTime ) ,
35+ typeof ( Nullable < DateTime > )
2836 } ;
2937
3038 public Parser ( IEnumerable < KeyValuePair < string , StringValues > > configParams , IQueryable < T > queriable )
@@ -239,14 +247,23 @@ private Expression<Func<T, bool>> GenerateEntityFilter()
239247 foreach ( var propMap in _propertyMap )
240248 {
241249 var property = propMap . Value . Property ;
242-
243- if ( ! property . CanWrite || ! propMap . Value . Searchable || ! _translatable . Any ( t => t == property . PropertyType ) )
250+ var isString = property . PropertyType == typeof ( string ) ;
251+ if ( ! property . CanWrite || ! propMap . Value . Searchable || ( ! _convertable . Any ( t => t == property . PropertyType ) && ! isString ) )
244252 {
245253 continue ;
246254 }
255+
256+ Expression propExp = Expression . Property ( paramExpression , property ) ;
257+
258+ if ( ! isString )
259+ {
260+ var toString = property . PropertyType . GetMethod ( "ToString" , Type . EmptyTypes ) ;
247261
248- var propExp = Expression . Property ( paramExpression , property ) ;
249- var toLower = Expression . Call ( propExp , typeof ( string ) . GetMethod ( "ToLower" , new Type [ 0 ] ) ) ;
262+ propExp = Expression . Call ( propExp , toString ) ;
263+
264+ }
265+
266+ var toLower = Expression . Call ( propExp , typeof ( string ) . GetMethod ( "ToLower" , Type . EmptyTypes ) ) ;
250267
251268 searchProps . Add ( Expression . Call ( toLower , typeof ( string ) . GetMethod ( "Contains" ) , searchExpression ) ) ;
252269
@@ -279,6 +296,8 @@ private class PropertyMapping
279296 public string SearchInput { get ; set ; } //Not yet implemented
280297 }
281298
299+
300+
282301 }
283302 public class FormatedList < T >
284303 {
0 commit comments