@@ -21,7 +21,9 @@ public static class IQueryableDynamicFilterExtensions
2121 { "startswith" , "StartsWith" } ,
2222 { "endswith" , "EndsWith" } ,
2323 { "contains" , "Contains" } ,
24- { "doesnotcontain" , "Contains" }
24+ { "doesnotcontain" , "Contains" } ,
25+ { "in" , "In" } ,
26+ { "between" , "Between" }
2527 } ;
2628
2729 public static IQueryable < T > ToDynamic < T > ( this IQueryable < T > query , DynamicQuery dynamicQuery )
@@ -93,7 +95,28 @@ public static string Transform(Filter filter, IList<Filter> filters)
9395 if ( filter . Operator == "doesnotcontain" )
9496 where . Append ( $ "(!np({ filter . Field } ).{ comparison } (@{ index . ToString ( ) } ))") ;
9597 else if ( comparison is "StartsWith" or "EndsWith" or "Contains" )
96- where . Append ( $ "(np({ filter . Field } ).{ comparison } (@{ index . ToString ( ) } ))") ;
98+ {
99+ if ( ! filter . CaseSensitive )
100+ {
101+ where . Append ( $ "(np({ filter . Field } ).ToLower().{ comparison } (@{ index . ToString ( ) } .ToLower()))") ;
102+ }
103+ else
104+ {
105+ where . Append ( $ "(np({ filter . Field } ).{ comparison } (@{ index . ToString ( ) } ))") ;
106+ }
107+ }
108+ else if ( filter . Operator == "in" )
109+ {
110+ where . Append ( $ "np({ filter . Field } ) in ({ filter . Value } )") ;
111+ }
112+ else if ( filter . Operator == "between" )
113+ {
114+ var values = filter . Value . Split ( ',' ) ;
115+ if ( values . Length != 2 )
116+ throw new ArgumentException ( "Invalid Value for 'between' operator" ) ;
117+
118+ where . Append ( $ "(np({ filter . Field } ) >= { values [ 0 ] } and np({ filter . Field } ) <= { values [ 1 ] } )") ;
119+ }
97120 else
98121 where . Append ( $ "np({ filter . Field } ) { comparison } @{ index . ToString ( ) } ") ;
99122 else if ( filter . Operator is "isnull" or "isnotnull" )
0 commit comments