QueryableExtension.ToFilterString on nullable properties

When using QueryableExtension.ToFilterString with a IEnumerable and a nullable target property value, a System.InvalidOperationException is thrown.

Demo:

Code:

    protected async Task BuildFilter()
    {
        var filters = new List<CompositeFilterDescriptor>
        {
            new CompositeFilterDescriptor
            {
                Property = "DemoValue",
                FilterOperator = FilterOperator.Contains,
                LogicalFilterOperator = LogicalFilterOperator.And,
                FilterValue = new long[] { 1, 2 }
            }
        };

        try
        {
            filterString = Radzen.QueryableExtension.ToFilterString<Demo>(filters, LogicalFilterOperator.And, FilterCaseSensitivity.CaseInsensitive);
        }
        catch (Exception ex)
        {
            filterString = ex.ToString();
        }
        StateHasChanged();
    }



    public class Demo
    {
        public string Title { get; set; }
        public long? DemoValue { get; set; }
    }

Exception:

No generic method 'Contains' on type 'System.Linq.Enumerable' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic.

This should match the property type - should be nullable as well.

1 Like

Thank you for that. I didn't realise they had to match but it makes sense they would.