Filter with nested AND - OR doesn't generate correct OData filter

Hi,

I need to generate an OData filter like

$filter=((A eq '1') or (B eq '1')) AND ((C contains 'sync') or (D contains 'fusion'))

how can I achieve this result?


With the following code it doesn't add the parentheses between the first two condition (A & B) and the second two (C & D).



WhereFilter filter1 = new WhereFilter();
var predicate1 = new List
{
new() { Condition = "or", Field = "A", value = "1", Operator = "equal", IgnoreCase = true, IgnoreAccent = true },
new() { Condition = "or", Field = "B", value = "2", Operator = "equal", IgnoreCase = true, IgnoreAccent = true },
}
filter1 = WhereFilter.And(predicate1); Query qry = new Query().Where(filter1); WhereFilter filter2 = new WhereFilter(); var predicate2 = new List { new() { Condition = "or", Field = "C", value = "sync", Operator = "contains", IgnoreCase = true, IgnoreAccent = true }, new() { Condition = "or", Field = "D", value = "fusion", Operator = "contains", IgnoreCase = true, IgnoreAccent = true }, } filter2 = WhereFilter.And(predicate2); qry = qry.Where(filter2);

1 Reply

SP Sarveswaran Palani Syncfusion Team July 4, 2022 03:25 PM UTC

Hi Nicola,


Thanks for contacting Syncfusion support


We have analyzed your query and still we are quite unclear about your exact requirement. So kindly share the following details to validate the reported query further at our end.

  1. Kindly mention the type of adaptor you are using at your end
  2. Share video demo of the issue you are facing., it’ll be more useful to us to understand your query
  3. Share more details about your requirement.


Above requested details will be helpful for us to validate the reported query at our end and provide solution as early as possible. 


Regards,

Sarveswaran PK


Loader.
Up arrow icon