OData - filter by nested property

Does anyone know how to express an OData $ filter against a nested property?

for ex. I have an Atom entry,

<entry> ... <m:properties> ... <d:RegardingObjectId m:type="Microsoft.Crm.Sdk.Data.Services.EntityReference"> <d:Id m:type="Edm.Guid">3f3712fd-fc49-e211-8eb8-000c296272c8</d:Id> <d:LogicalName>new_sportsleague</d:LogicalName> <d:Name>Boca</d:Name> </d:RegardingObjectId> 

I want to filter those records that have RegardingObjectId / LogicalName eq 'new_sportsleague'.

Tried "RegardingObjectId / LogicalName" and "RegardingObjectId.LogicalName" with no luck.

+6
source share
2 answers

'RegardingObjectId/LogicalName' will be the correct syntax.

For instance:

http://services.odata.org/v3/OData/OData.svc/Suppliers

returns two results, whereas

http://services.odata.org/v3/OData/OData.svc/Suppliers ? $ filter = Address / Street eq 'NE 228th'

returns only one.

I don't see a place in the OData specification that explicitly indicates whether filtering using complex value properties is legal or not, but it looks like WCF support services support it. Perhaps other OData implementations do not.

+10
source

Use the following odata API example to access nested properties with filter data.

 http://192.168.50.152:50086/odata/StationOperationLogs/?$expand=ProductionStation,ProductionStation/ProductionUnit&$filter=ProductionStation/ProductionUnit/Id eq 2 
0
source

Source: https://habr.com/ru/post/945085/


All Articles