问题
why the cast is not working here?
http://services.odata.org/Northwind/Northwind.svc/Orders?$filter=startswith(cast(OrderID, 'Edm.String'),'1')
it says:
No coercion operator is defined between types 'System.Int32' and 'System.String'.
回答1:
OData doesn't support conversion to and from string. It supports conversions between related entity types and between numeric primitive types only. See http://msdn.microsoft.com/en-us/library/dd541472(v=PROT.10).aspx and the castExpression paragraph. It's very similar to the cast operator in C# for example.
来源:https://stackoverflow.com/questions/8456013/casting-int-to-string-in-odata-raises-error