I am also facing similar problems, there is this sap note:
https://apps.support.sap.com/sap/support/knowledge/en/3008698
Copy of the note details:
BEGIN OF NOTE
Symptom
After adding a filter
$filter = To_Employees/Name eq 'Hugo' to an Odata service, there is an error:
"Left hand expression of memberaccess operator has wrong cardinality (to many not allowed)"
Environment
SAP_GWFND 750
Reproducing the Issue
Access the odata service: /sap/opu/odata/sap/API_XXX_SRV/Orgnization$select=Orgnization,to_Employees/Name&$expand=to_Employees&$filter=to_Employees/Name eq 'Hugo'
There is an error: "Left hand expression of memberaccess operator has wrong cardinality (to many not allowed)"
Cause
"Left hand expression of memberaccess operator has wrong cardinality (to many not allowed)" indicates that "to_Employees"is a to-many navigation, and this is not supported in combination with a filter expression (e.g.
$filter = To_Employees/Name eq 'Hugo',
when "To_Employees" points to more than one employee ).
Therefore, the whole request is invalid.
Resolution
Remove the filter, do not combine to many results with filter eq
END OF NOTE
I don't like the solution presented :)
The workaround solution I have implemented was to create an entity which has cardinality 1:1 just for filtering.
In your example, I assume you need the cardinaliy of the relationship from Foo to Bar to be 1:n in order to be able to receive multiple Bar records for each Foo found. If the relationship Foo to Bar is 1:1, you can simply change the cardinality and you are good to go. If you need cardinality 1:n, you may create an entity like BarFilter which is related to Foo with 1:1 cardinality. Then you would be able to execute this request without errors and can receive the filters to make the corresponding query on your backend system. The request would be something like:
New simple entity:
BarFilter
Foo has a 1:1 association to new entity BarFilter.
Request:
/sap/opu/odata/sap/ZTEST_SRV/Foo?$filter=Key gt 10 and BarFilter/Id gt 2&$expand=Bar
I hope this is clear and that it helps you.
I am very interested in this topic so if you find something interesting, please share it.
Have a nice weekend.
Cheers