user3057544
user3057544

Reputation: 868

OData - how to exclude empty items from result

I have below OData query:

http://myApp/odata/Suppliers?$expand=SkillTasks($filter=TaskId eq 14)&$select=Id,Name

I get all Suppliers. Included SkillTasks are with Id=14 only or empty if given Supplier doesn't have SkillTask with Id=14.

What I expect is: only Suppliers having SkillTask with Id=14. If given Supplier doesn't have SkillTask with Id=14 he/she shouldn't be returned.

I think I should use filter on Supplier instead on SkillTasks but I dont know how to reference to SkillTask there

http://myApp/odata/Suppliers?$filter=(SkillTasks.TaskId eq 14)&$expand=SkillTasks&$select=Id,Name

Upvotes: 0

Views: 581

Answers (1)

user2250152
user2250152

Reputation: 20605

I would expect that $filter inside $expand will work but you can use $filter with any operator.

http://myApp/odata/Suppliers?$expand=SkillTasks&$filter=SkillTasks/any(r:r/TaskId eq 14)&$select=Id,Name

Upvotes: 1

Related Questions