Invalid OData Filter

So I may be just doing something completely wrong (or overlooking a flag somewhere).

I have a fairly basic RadDataGrid connected up to a OData source with filtering enabled (for the purposes of this question, I've simplified it to the ApplicationUsers table - don't worry its not actually using this table so no security risk).

The RadDataGrid is pretty simplistic -

<RadzenDataGrid Data="@userList" Count="@count" @ref="userGrid" LoadData="@LoadData" TItem="ApplicationUserListViewModel"
                AllowFiltering="true" AllowSorting="true">
	<Columns>
		<RadzenDataGridColumn TItem="ApplicationUserListViewModel" Property="Id" Title="Id" Width="350px" />
		<RadzenDataGridColumn TItem="ApplicationUserListViewModel" Property="NormalizedUserName" Title="Username"></RadzenDataGridColumn>
		<RadzenDataGridColumn TItem="ApplicationUserListViewModel">
			<Template Context="card">
				<RadzenButton ButtonStyle="ButtonStyle.Danger" Icon="close" Size="ButtonSize.Small" Click="@(args => DeleteRow(card))"  @onclick:stopPropagation="true">
				</RadzenButton>
			</Template>
			<EditTemplate Context="card">
				<RadzenButton ButtonStyle="ButtonStyle.Danger" Icon="close" Size="ButtonSize.Small" Click="@(args => DeleteRow(card))">
				</RadzenButton>
			</EditTemplate>
		</RadzenDataGridColumn>
	</Columns>
</RadzenDataGrid>

When however I type anything in the query form I get a $filter as follows -

$filter=(NormalizedUserName+%3d%3d+null+%3f+%27%27+%3a+NormalizedUserName).Contains(%27mitch%27)

The problem with this is that when .net interprits the $filter it generates the following error -

"The query specified in the URI is not valid. ')' or operator expected at position 20 in '(NormalizedUserName == null ? '' : NormalizedUserName).Contains('mitch')'."

Is there a flag or switch to enable OData compatible filters that I am maybe missing?

Working example with OData service can be found here:
https://blazor.radzen.com/datagrid-odata

The key is AsODataEnumerable() extension method which tells the DataGrid to provide valid OData filters, sorts, etc.

1 Like

Thanks - that nugget of info helped resolve the problem. I was applying a .ToList() afterward not realizing it needed that specific data type.