Combining ANY() queries

Multiple Any() as well as !Any() clauses can be combined by the AND operator which enables you to create complex queries in your OData code.

The following example illustrates how to query for Files that have at least one Party with role (CustomLabel) of “Udvalg” OR “Medlem” AND also has a Party with role “Formand” AND also does NOT have a Party with role “Klager”.

Example:


var query =
from f in context.Files
where
f.Parties.Any(p => p.CustomLabel_Value == "Udvalg" || p.CustomLabel_Value == "Medlem") &&
f.Parties.Any(p => p.CustomLabel_Value == "Formand") &&
!f.Parties.Any(p => p.CustomLabel_Value == "Klager")
select new File { ID = f.ID };
// Equivalent Url: Files?$filter=Parties/any(p:p/CustomLabel_Value eq 'Udvalg' or p/CustomLabel_Value eq 'Medlem') and Parties/any(p:p/CustomLabel_Value eq 'Formand') and not Parties/any(p:p/CustomLabel_Value eq 'Klager')&$select=ID

The copy image is missing