I'm experiencing an issue with this filter type under the following use case:
- Column type is: decimal?
- Filter mode is CheckBoxList
- Sort by this column
- Select a filter in the checkboxlist dropdown
The following error pops up:
System.InvalidOperationException: The binary operator Equal is not defined for the types 'System.Nullable`1[System.Decimal]' and 'System.Linq.EnumerableQuery`1[System.Nullable`1[System.Decimal]]'.
Interestingly enough, it does not happen if I don't sort the column before applying the filter.
I have prepared a reproducible razor file for this:
@page "/TestingGridError3"
@using Satellite.Components.Pages.Auth
@layout LoginLayout
<RadzenDataGrid @bind-Value=@selectedItems Data="@data" TItem="IDictionary<string, object>" ColumnWidth="200px"
AllowFiltering="true" FilterPopupRenderMode="PopupRenderMode.OnDemand" FilterMode="FilterMode.CheckBoxList"
AllowPaging="true" AllowSorting="true">
<Columns>
@foreach (var column in Columns)
{
<RadzenDataGridColumn @key=@column.Key Title="@column.Key" Type="column.Value"
Property="@PropertyAccess.GetDynamicPropertyExpression(column.Key, column.Value)">
<Template>
@context[@column.Key]
</Template>
</RadzenDataGridColumn>
}
</Columns>
</RadzenDataGrid>
<RadzenButton Click="TriggerBreakPoint">trigger breakpoint</RadzenButton>
@code {
IList<IDictionary<string, object>> selectedItems;
private IEnumerable<IDictionary<string, object>> data { get; set; }
private IDictionary<string, Type> Columns { get; set; }
public enum EnumTest
{
EnumValue1,
EnumValue2
}
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
Columns = new Dictionary<string, Type>()
{
{ "Employee ID", typeof(int?) },
{ "MyColumn", typeof(EnumTest?) },
{ "FirstName", typeof(string) },
{ "LastName", typeof(string) },
{ "HireDate", typeof(DateTime?) },
{ "DateOnly", typeof(DateTime?) },
{ "TimeOnly", typeof(DateTime?) },
{ "UID", typeof(Guid?) },
{ "Salary", typeof(decimal?) },
};
foreach (var i in Enumerable.Range(0, 50))
{
Columns.Add($"Column{i}", typeof(string));
}
var random = new Random();
data = Enumerable.Range(0, 100).Select(i =>
{
return Columns.ToDictionary<KeyValuePair<string, Type>, string, object>(column => column.Key, column => (column.Value == typeof(EnumTest?)
? i == 0 ? null : (i % 2 == 0 ? EnumTest.EnumValue1 : EnumTest.EnumValue2)
: column.Value == typeof(int?)
? i == 0 ? null : i
: column.Value == typeof(DateTime?)
? i == 0 ? null : DateTime.Now.AddDays(random.Next(-365, 365)).AddHours(random.Next(0, 24)).AddMinutes(random.Next(0, 60)).AddSeconds(random.Next(0, 60))
: column.Value == typeof(Guid?)
? i == 0 ? null : Guid.NewGuid()
: column.Value == typeof(decimal?)
? i == 0 ? null : (decimal?)random.Next(30000, 150000) + (decimal)random.NextDouble()
: $"{column.Key}{i}")!);
}).ToList();
}
private Task TriggerBreakPoint()
{
var foo = 3;
return Task.CompletedTask;
}
}