Issue with Query Builder

I have used the Northwind SQL Server Sample Database and created a .NET 8 Blazor Server App.

Here's the Query Builder for the OnInitializedAsync()

I add a filter group with "And" effectively meaning data will be limited to Country = Brazil

However, if I click OK and come back, the "And" group is lost and the filter is in the "Or" group.

Am I doing something wrong or is this a Radzen Blazor Studio issue?

Hi @kirank,

This is by design. A group with only one item is flattened automatically as an optimization.

Hi @korchev.

Noted. Makes sense if both groups are of type "Or" or of type "And". But if one is "Or" and another is "And" per my example, it doesn't make sense and the result is incorrect.

Noted that if I manually amended the source and put brackets, then there is no flattening by the UI as suggested.

Why do you want to have groups with one item to begin with? What is the expression you want to achieve?

@korchev

Say I want to achieve this via the Query Builder

    protected override async Task OnInitializedAsync()
    {
        customers = await NorthwindDBService.GetCustomers(new Radzen.Query { Filter = "i => (i.CustomerID.Contains(@0) || i.CompanyName.Contains(@1) || i.ContactName.Contains(@2) || i.ContactTitle.Contains(@3) || i.Address.Contains(@4) || i.City.Contains(@5) || i.Region.Contains(@6) || i.PostalCode.Contains(@7) || i.Phone.Contains(@8) || i.Fax.Contains(@9)) && i.Country == @10", FilterParameters = new object[] { search, search, search, search, search, search, search, search, search, search, "Germany" }, OrderBy = "Country asc" });
    }

The rational being, say a user can only see Customers for their Country.

The code is edited in source. How can I achieve this via the Query Builder?

Hi @kirank,

Based on the query, you need to create an OR group inside an AND group:

This will result in ((Item1 || Item2 || Item3) && Item4)

1 Like