0
votes

I have an int field in the database that my Odata service is connecting too. Im wondering if it is possible to do a StartsWith filter on the integer field.

e.g. http://services.odata.org/Northwind/Northwind.svc/Customers?$filter=startswith(CustomerID, '1') eq true

Where in this example the CustomerID will be an int field. Currently im getting a Error 400 response, which im gathering is because you cannot perform the startswith on the int field. Can I somehow cast the field in the filter?

Thanks in advance

2

2 Answers

10
votes

Try this:

$filter=(startswith(cast(CustomerID, 'Edm.String'),'1'))  
0
votes

Don't know about that... maybe you can do something like this:

$filter=(Id gt 0 and Id lt 2) or (Id gt 9 and Id lt 20) or (Id gt 99 and Id lt 200)...