I'm an oData newbie and trying to construct the $filter parameter that will behave like a "LIKE" sql statement.
Lets say on the Name textbox the user enters the "ABC", this equates to "$filter=name eq 'ABC'".
- User enters "ABC*", code should produce "name startswith 'abc'".
- User enters "*ABC", code should produce "name endswith 'abc'".
- User enters "A*C", code should produce "name startswith 'a' and name endswith 'c'".
- Nice to have if it can also do "A*B*C" or more complex variation, but not a requirement.
Now, I can write a little javascript method that may go like this....(pseudo only) (if first character is == "") ? "blah startswith 'ABC'" : "" + (if last character is == "") ? "blah endswith 'ABC'" : "" ...etc..or may be some regex
But its not elegant I'm not sure this is the right approach, Is there any other way to handle LIKEs with oData. Is it possible to pass "blah eq '*A*B*C*'" and modify the options within the Controller to force the option to generate a "LIKE" ?
Note: Not asking for a actual code, just an idea on what approach may work...
Regards, Mike
*A*B*C*
? – Iłya Bursov