Please check the example provided in the manual under the title Multi-entity filters
in the following path: "Using the generated code -> Adapter/SelfServicing -> Filtering and sorting -> Advanced filter usage"
Also in the docs check the example at How do I filter on fields in another entity?
in the following path: "Best practises -> How do I ... ?"