RadzenDataFilter and Nullable DateTimeOffset Exception

The following exception is thrown if a DateTimeOffset? property is used in a RadzenDataFilter for any FilterType.

The binary operator GreaterThan is not defined for the types 'System.Nullable`1[System.DateTimeOffset]' and 'System.DateTime'.

DateTime, DateTime? and DateTimeOffset all work fine.

Thanks for the report. We will check what’s going on and we will provide fix in our next update next week.

1 Like

Just wondering if there is there any update on this, as I'm still experiencing the same issue with 4.7.1

Unfortunately we've not found time to look at this issue. If something is urgent for you, you can attach the source code of Radzen.Blazor to debug your case - you can even submit a pull request with a fix. Paid support is also an option, check our pricing page for reference.

Using UtcDateTime sub property of the DateTimeOffset when specifying RadzenDataFilterProperty Property will resolve your issue.

Thanks, I'm raising a purchase request to get paid support as I'm very impressed with the component set and definitely see extensive use of the range in the future of our product.

I've had a look and the issue seems to be that the RadzenDatePicker for a DataFilter always returns a DateTime regardless of the bound property type meaning the resulting CompositeFilterDescriptor is also of type DateTime. This then causes an exception in

public static IQueryable<T> Where<T>(this IQueryable<T> source, RadzenDataFilter<T> dataFilter)

Here is some example code required to replicate the issue:

<div class="container-fluid">
    <div class="row">
        <div class="col">
            <RadzenCard class="mb-3">
                <RadzenDataFilter Auto="true" Data="@LogMessages" TItem="LogMessage">
                        <RadzenDataFilterProperty TItem="LogMessage" Property="Timestamp" Title="Timestamp" />

@code {
    IList<LogMessage> LogMessages = new List<LogMessage>
        new LogMessage {Message = "Message 1", Timestamp = DateTimeOffset.Now},
        new LogMessage {Message = "Message 2", Timestamp = null},
        new LogMessage {Message = "Message 3", Timestamp = DateTimeOffset.Now.AddMinutes(1)},

    private class LogMessage
        public string Message { get; set; }
        public DateTimeOffset? Timestamp { get; set; }

Check my previous reply:

Like this?

<RadzenDataFilterProperty TItem="LogMessage" Property="Timestamp.UtcDateTime" Type=@(typeof(DateTime)) Title="Timestamp" />

There is no setter for DateTimeOffset.UtcDateTime so this fails with a new error:

Error: No property or field 'UtcDateTime' exists in type 'DateTimeOffset?'

The next update (tomorrow) will handle internally DateTimeOffset:

Great, thank you :+1: