1
1
using System ;
2
+ using System . Collections ;
2
3
using System . Collections . Generic ;
3
4
using System . Linq ;
4
5
using System . Linq . Expressions ;
@@ -146,12 +147,12 @@ public Table<TModel> Filter<TCriterion>(string columnName, Operator op, TCriteri
146
147
case float floatCriterion :
147
148
_filters . Add ( new QueryFilter ( columnName , op , floatCriterion ) ) ;
148
149
return this ;
149
- case List < object > listCriteria :
150
- _filters . Add ( new QueryFilter ( columnName , op , listCriteria ) ) ;
151
- return this ;
152
- case Dictionary < string , object > dictCriteria :
150
+ case IDictionary dictCriteria :
153
151
_filters . Add ( new QueryFilter ( columnName , op , dictCriteria ) ) ;
154
152
return this ;
153
+ case IList listCriteria :
154
+ _filters . Add ( new QueryFilter ( columnName , op , listCriteria ) ) ;
155
+ return this ;
155
156
case IntRange rangeCriteria :
156
157
_filters . Add ( new QueryFilter ( columnName , op , rangeCriteria ) ) ;
157
158
return this ;
@@ -810,18 +811,19 @@ internal KeyValuePair<string, string> PrepareFilter(QueryFilter filter)
810
811
811
812
break ;
812
813
case Operator . In :
813
- if ( filter . Criteria is List < object > inCriteria && filter . Property != null )
814
+ if ( filter is { Criteria : IList inCriteria , Property : not null } )
814
815
{
815
816
foreach ( var item in inCriteria )
816
817
strBuilder . Append ( $ "\" { item } \" ,") ;
817
818
818
819
return new KeyValuePair < string , string > ( filter . Property ,
819
820
$ "{ asAttribute . Mapping } .({ strBuilder . ToString ( ) . Trim ( ',' ) } )") ;
820
821
}
821
- else if ( filter . Criteria is Dictionary < string , object > dictCriteria && filter . Property != null )
822
+
823
+ if ( filter is { Criteria : IDictionary inDictCriteria , Property : not null } )
822
824
{
823
825
return new KeyValuePair < string , string > ( filter . Property ,
824
- $ "{ asAttribute . Mapping } .{ JsonConvert . SerializeObject ( dictCriteria ) } ") ;
826
+ $ "{ asAttribute . Mapping } .{ JsonConvert . SerializeObject ( inDictCriteria ) } ") ;
825
827
}
826
828
827
829
break ;
@@ -830,15 +832,15 @@ internal KeyValuePair<string, string> PrepareFilter(QueryFilter filter)
830
832
case Operator . Overlap :
831
833
switch ( filter . Criteria )
832
834
{
833
- case List < object > listCriteria when filter . Property != null :
835
+ case IList listCriteria when filter . Property != null :
834
836
{
835
837
foreach ( var item in listCriteria )
836
838
strBuilder . Append ( $ "{ item } ,") ;
837
839
838
840
return new KeyValuePair < string , string > ( filter . Property ,
839
841
$ "{ asAttribute . Mapping } .{{{strBuilder.ToString().Trim(',')}}}") ;
840
842
}
841
- case Dictionary < string , object > dictCriteria when filter . Property != null :
843
+ case IDictionary dictCriteria when filter . Property != null :
842
844
return new KeyValuePair < string , string > ( filter . Property ,
843
845
$ "{ asAttribute . Mapping } .{ JsonConvert . SerializeObject ( dictCriteria ) } ") ;
844
846
case IntRange rangeCriteria when filter . Property != null :
@@ -852,7 +854,7 @@ internal KeyValuePair<string, string> PrepareFilter(QueryFilter filter)
852
854
case Operator . NotRightOf :
853
855
case Operator . NotLeftOf :
854
856
case Operator . Adjacent :
855
- if ( filter . Criteria is IntRange rangeCriterion && filter . Property != null )
857
+ if ( filter is { Criteria : IntRange rangeCriterion , Property : not null } )
856
858
{
857
859
return new KeyValuePair < string , string > ( filter . Property ,
858
860
$ "{ asAttribute . Mapping } .{ rangeCriterion . ToPostgresString ( ) } ") ;
@@ -863,7 +865,7 @@ internal KeyValuePair<string, string> PrepareFilter(QueryFilter filter)
863
865
case Operator . PHFTS :
864
866
case Operator . PLFTS :
865
867
case Operator . WFTS :
866
- if ( filter . Criteria is FullTextSearchConfig searchConfig && filter . Property != null )
868
+ if ( filter is { Criteria : FullTextSearchConfig searchConfig , Property : not null } )
867
869
{
868
870
return new KeyValuePair < string , string > ( filter . Property ,
869
871
$ "{ asAttribute . Mapping } ({ searchConfig . Config } ).{ searchConfig . QueryText } ") ;
0 commit comments