@@ -74,49 +74,32 @@ private List<FilterQuery> ParseFilterQuery(string key, string value)
74
74
var queries = new List < FilterQuery > ( ) ;
75
75
76
76
var propertyName = key . Split ( '[' , ']' ) [ 1 ] . ToProperCase ( ) ;
77
- var attribute = GetAttribute ( propertyName ) ;
78
-
79
- if ( attribute == null )
80
- throw new JsonApiException ( "400" , $ "{ propertyName } is not a valid property.") ;
81
77
82
78
var values = value . Split ( ',' ) ;
83
79
foreach ( var val in values )
84
- queries . Add ( ParseFilterOperation ( attribute , val ) ) ;
80
+ {
81
+ ( var operation , var filterValue ) = ParseFilterOperation ( val ) ;
82
+ queries . Add ( new FilterQuery ( propertyName , filterValue , operation ) ) ;
83
+ }
85
84
86
85
return queries ;
87
86
}
88
87
89
- private FilterQuery ParseFilterOperation ( AttrAttribute attribute , string value )
88
+ private ( string operation , string value ) ParseFilterOperation ( string value )
90
89
{
91
90
if ( value . Length < 3 )
92
- return new FilterQuery ( attribute , value , FilterOperations . eq ) ;
91
+ return ( string . Empty , value ) ;
93
92
94
93
var operation = value . Split ( ':' ) ;
95
94
96
95
if ( operation . Length == 1 )
97
- return new FilterQuery ( attribute , value , FilterOperations . eq ) ;
96
+ return ( string . Empty , value ) ;
98
97
99
98
// remove prefix from value
100
99
var prefix = operation [ 0 ] ;
101
100
value = operation [ 1 ] ;
102
101
103
- switch ( prefix )
104
- {
105
- case "eq" :
106
- return new FilterQuery ( attribute , value , FilterOperations . eq ) ;
107
- case "lt" :
108
- return new FilterQuery ( attribute , value , FilterOperations . lt ) ;
109
- case "gt" :
110
- return new FilterQuery ( attribute , value , FilterOperations . gt ) ;
111
- case "le" :
112
- return new FilterQuery ( attribute , value , FilterOperations . le ) ;
113
- case "ge" :
114
- return new FilterQuery ( attribute , value , FilterOperations . ge ) ;
115
- case "like" :
116
- return new FilterQuery ( attribute , value , FilterOperations . like ) ;
117
- }
118
-
119
- throw new JsonApiException ( "400" , $ "Invalid filter prefix '{ prefix } '") ;
102
+ return ( prefix , value ) ; ;
120
103
}
121
104
122
105
private PageQuery ParsePageQuery ( string key , string value )
0 commit comments