简体   繁体   中英

Change field type in Odata OrderBy

I have OdataService with CustDetails table (I am using Entity Framework ). In the table I have column PostalCode of string type. When I sort the data it working fine. It sort the data by considering it as string type. But my requirement is, in my PostalCode all values are integer value only , so I need to sort the data by considering it as integer type. Is it possible to change the field data type while sorting ?

Actual sorted Result:

100,
1100,
12,
2,
200

But My expected result is

2,
12,
100,
200,
1100

Please help me to overcome this. Note : I am not able to change the data type in database.

OData doesn't support conversion of primitive types in the query. See Odata Query String Options

You could, however, write a service operation to handle this for you (assuming your query provider supports this).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM