2
votes

Currently I am facing some issues while querying the oData services. I am very new to oData query syntax.

I am trying to query oData service using the following url

https://mysite/DataQueryGroups?$select=Id,Name&$filter=IsHidden eq false&IsShared ne false&$expand=DataQueries($select=Id,Name,IsPinned;)

which returns the desired results to me. Above query basically returns all DataQueryGroups where IsHidden=false and IsShared<>false, including the its child entity DataQueries. Now I want to add filter to the DataQueries enity to display only those resulsts where IsPinned = true. So I have tried the following query

https://mysite/DataQueryGroups?$select=Id,Name&$filter=IsHidden eq false&IsShared ne false&$expand=DataQueries($select=Id,Name,IsPinned;$filter=IsPinned eq true;)

But this returns me the same results and it looks like its not considering the inner filter/last filter which I have specified on DataQueries entity.

I would like to know how to filter on parent and child entities and return the fields from both.

I am finding difficulties to under this syntax. Please let me know if anybody can help me on this issue.

I am using oData version 4.0

Thanking you in advance Deepak

1

1 Answers

0
votes

@Deepak

It seems that the latest Web API OData (v5.7) supports the nested filter in expand. See this issue: https://github.com/OData/WebApi/issues/127

I also wrote a sample project based on your model. It works on my side.

Would you please run it at your side and let me know any result. Thanks.