@@ -74,49 +74,32 @@ private List<FilterQuery> ParseFilterQuery(string key, string value)
7474 var queries = new List < FilterQuery > ( ) ;
7575
7676 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.") ;
8177
8278 var values = value . Split ( ',' ) ;
8379 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+ }
8584
8685 return queries ;
8786 }
8887
89- private FilterQuery ParseFilterOperation ( AttrAttribute attribute , string value )
88+ private ( string operation , string value ) ParseFilterOperation ( string value )
9089 {
9190 if ( value . Length < 3 )
92- return new FilterQuery ( attribute , value , FilterOperations . eq ) ;
91+ return ( string . Empty , value ) ;
9392
9493 var operation = value . Split ( ':' ) ;
9594
9695 if ( operation . Length == 1 )
97- return new FilterQuery ( attribute , value , FilterOperations . eq ) ;
96+ return ( string . Empty , value ) ;
9897
9998 // remove prefix from value
10099 var prefix = operation [ 0 ] ;
101100 value = operation [ 1 ] ;
102101
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 ) ; ;
120103 }
121104
122105 private PageQuery ParsePageQuery ( string key , string value )
0 commit comments