简体   繁体   中英

How to cast a property of type Edm.String to numeric in Odata V2

I am querying a Odata V2 service. The entity Foo has a property Bar of type Edm.String. Bar is a time in milliseconds that, sadly, was defined as a string. Eg "1597091642312".

How can I query Foo for results where Bar is only after a specific point in time?

I tried to cast, like this:

/Bar?$filter=cast(Foo,Edm.Int64) gt 631148400000

But then I get:

Feature is not supported: Expression "5" in $filter or $orderby query options

Especially the '5' does not make sense to me.

The providing service is a SAP CAP CDS mock service, using a V4 to V2 proxy.

Ok so it seems that you can do this:

/Bar?$filter=Foo gt '631148400000'

And no cast should be necessary. I assume the gt is applied alphanumerically, which has the same effect if it were applied numerically?

However, when using the timestamp 631148400000 I get no results (which pushed me in the direction of String being a problem). I do get results with a more recent timestamp (in 2019 or 2020).

I am not sure if this is a Odata V2 problem, or a problem with my SAP CDS mock service.

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