# Issue with Dynamic Filtering After Upgrading to Radzen 6.0.x

**URL:** <https://forum.radzen.com/t/issue-with-dynamic-filtering-after-upgrading-to-radzen-6-0-x/19763>\
**Category:** Radzen.Blazor Components\
**Created:** [February 15, 2025, 7:45am UTC](https://forum.radzen.com/t/issue-with-dynamic-filtering-after-upgrading-to-radzen-6-0-x/19763 "2025-02-15T07:45:32Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![JustJoe](https://forum.radzen.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@JustJoe](https://forum.radzen.com/u/JustJoe)\
**Post date:** [February 18, 2025, 3:48pm UTC](https://forum.radzen.com/t/issue-with-dynamic-filtering-after-upgrading-to-radzen-6-0-x/19763/41 "2025-02-18T15:48:49Z")

</div>

Thanks. However, this does not give the result that I need. The idea is this:

The property DateCreated always has a value while DateProcessed may be null in some cases.

Now, I want to genreally sort by DateProcessed desc but in case the field is null, it should use DateCreated as fallback value for the sorting order. With v5 this was possible using the coalescing operator.

---

<div class="post-metadata">

**Author:** ![enchev](https://forum.radzen.com/user_avatar/forum.radzen.com/enchev/32/16_2.png) [@enchev](https://forum.radzen.com/u/enchev)\
**Post date:** [February 18, 2025, 3:51pm UTC](https://forum.radzen.com/t/issue-with-dynamic-filtering-after-upgrading-to-radzen-6-0-x/19763/42 "2025-02-18T15:51:48Z")

</div>

Thanks for the clarification! We will research on how to restore this functionality and I'll update this thread when ready. The fix for more than two hierarchy levels of sub properties in Select() predicate was just published.

---

<div class="post-metadata">

**Author:** ![JustJoe](https://forum.radzen.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@JustJoe](https://forum.radzen.com/u/JustJoe)\
**Post date:** [February 18, 2025, 3:57pm UTC](https://forum.radzen.com/t/issue-with-dynamic-filtering-after-upgrading-to-radzen-6-0-x/19763/43 "2025-02-18T15:57:31Z")

</div>

Thanks a lot! Maybe the LINQ ThenByDescending could be a way to implement that. However, the coalescing operator would be the best option since it also can be used for other things in this context.

The fix for more than two hierarchy levels of sub properties in Select() predicate works fine! However, one should note that in case of sub properties, it is required to add a "as", so

Contact.Name

will give an exception, while

Contact.Name as ContactName

works as expected. Simple properties do not require that, so you can both use

AccountNo

or

AccountNo as AccountNo

---

<div class="post-metadata">

**Author:** ![JustJoe](https://forum.radzen.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@JustJoe](https://forum.radzen.com/u/JustJoe)\
**Post date:** [February 19, 2025, 10:42am UTC](https://forum.radzen.com/t/issue-with-dynamic-filtering-after-upgrading-to-radzen-6-0-x/19763/44 "2025-02-19T10:42:21Z")

</div>

I did some testing with the latest version and everything seems to work now after the upgrade to version 6.0.

The only thing that is missing is

> [@JustJoe](#):
>
> OrderBy = $"x =\> x.DateProcessed ?? x.DateCreated desc",

which worked before in version 5.0. It would be great if there is a chance to get the functionality restored.

Thanks a lot for your super quick help on the other issues so far!

---

<div class="post-metadata">

**Author:** ![enchev](https://forum.radzen.com/user_avatar/forum.radzen.com/enchev/32/16_2.png) [@enchev](https://forum.radzen.com/u/enchev)\
**Post date:** [February 19, 2025, 11:19am UTC](https://forum.radzen.com/t/issue-with-dynamic-filtering-after-upgrading-to-radzen-6-0-x/19763/45 "2025-02-19T11:19:49Z")

</div>

> [@JustJoe](#):
>
> OrderBy = $"x =\> x.DateProcessed ?? x.DateCreated desc",

This should be supported in latest version as well. Do you have any exceptions?

---

<div class="post-metadata">

**Author:** ![JustJoe](https://forum.radzen.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@JustJoe](https://forum.radzen.com/u/JustJoe)\
**Post date:** [February 19, 2025, 12:22pm UTC](https://forum.radzen.com/t/issue-with-dynamic-filtering-after-upgrading-to-radzen-6-0-x/19763/46 "2025-02-19T12:22:33Z")

</div>

> [@JustJoe](#):
>
> $"x =\> x.DateProcessed ?? x.DateCreated desc",

Well, if I use the syntax above, I get this exception:

System.ArgumentException: 'x' is not a member of type 'MyApp.Models.MyDataContext.Purchase' (Parameter 'propertyOrFieldName')  
at System.Linq.Expressions.Expression.PropertyOrField(Expression expression, String propertyOrFieldName)  
at Radzen.QueryableExtension.GetNestedPropertyExpression(Expression expression, String property, Type type)

However, if I change it to:

$"DateProcessed ?? DateCreated desc"

I do not get an exception, but it gives the same results as

$"DateProcessed desc"

so the other property is ignored.

As a result, the data is sorted descending by DateProcessed and all records, where DateProcessed is NULL are shown at the end of the resultset. The correct behaviour would be that for those records with DateProcessed == NULL the value of DateCreated is used instead to determine the position in the sort order.

---

<div class="post-metadata">

**Author:** ![enchev](https://forum.radzen.com/user_avatar/forum.radzen.com/enchev/32/16_2.png) [@enchev](https://forum.radzen.com/u/enchev)\
**Post date:** [February 19, 2025, 12:25pm UTC](https://forum.radzen.com/t/issue-with-dynamic-filtering-after-upgrading-to-radzen-6-0-x/19763/47 "2025-02-19T12:25:59Z")

</div>

Can you confirm if you are using 6.0.15 version?

---

<div class="post-metadata">

**Author:** ![JustJoe](https://forum.radzen.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@JustJoe](https://forum.radzen.com/u/JustJoe)\
**Post date:** [February 19, 2025, 1:09pm UTC](https://forum.radzen.com/t/issue-with-dynamic-filtering-after-upgrading-to-radzen-6-0-x/19763/48 "2025-02-19T13:09:52Z")

</div>

Yes, that is the version I'm currently using.

---

<div class="post-metadata">

**Author:** ![enchev](https://forum.radzen.com/user_avatar/forum.radzen.com/enchev/32/16_2.png) [@enchev](https://forum.radzen.com/u/enchev)\
**Post date:** [February 19, 2025, 1:14pm UTC](https://forum.radzen.com/t/issue-with-dynamic-filtering-after-upgrading-to-radzen-6-0-x/19763/49 "2025-02-19T13:14:23Z")

</div>

This works in our demo:

 ![image](https://forum.radzen.com/uploads/default/original/3X/7/1/71ff829912eb6685f23531f73bdf9db356645f3c.png)  
 ![image](https://forum.radzen.com/uploads/default/original/3X/6/5/65fa86980f5aa67bf3554eee9561bbf6c6c903d2.png)  
 ![image](https://forum.radzen.com/uploads/default/original/3X/8/c/8c676be92762e379845b7edc88e22438884cc172.png)

---

<div class="post-metadata">

**Author:** ![JustJoe](https://forum.radzen.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@JustJoe](https://forum.radzen.com/u/JustJoe)\
**Post date:** [February 19, 2025, 1:32pm UTC](https://forum.radzen.com/t/issue-with-dynamic-filtering-after-upgrading-to-radzen-6-0-x/19763/50 "2025-02-19T13:32:10Z")

</div>

Very strange. I'm not using this with the export controller but even if I leave the filter expression blank and only use the orderby expression I get an error as soon as I use the x =\> x. syntax. If I only supply the property names, it works but only sorts after the first property and ignores the ?? and the second property...

---

<div class="post-metadata">

**Author:** ![JustJoe](https://forum.radzen.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@JustJoe](https://forum.radzen.com/u/JustJoe)\
**Post date:** [February 19, 2025, 3:41pm UTC](https://forum.radzen.com/t/issue-with-dynamic-filtering-after-upgrading-to-radzen-6-0-x/19763/51 "2025-02-19T15:41:41Z")

</div>

Ok, I think I found a way to reproduce the issue:

Scaffold the Northwind database. In the Customers page, change the method that loads the data into the grid by adding a Query:

```auto
        protected override async Task OnInitializedAsync()
        {
            customers = await NorthwindDataService.GetCustomers(new Query() { OrderBy = "i => i.Region ?? i.Country desc" });
        }

```

I selected "Region" and "Country" for this example, because every record has a Country but not necessarily a Region, so if Region is NULL, it should use Country as fallback for the sorting order.

When you run the code and open the page, you get this Exception:

System.ArgumentException: 'i' is not a member of type 'Northwind.Models.NorthwindData.Customer' (Parameter 'propertyOrFieldName')  
at System.Linq.Expressions.Expression.PropertyOrField(Expression expression, String propertyOrFieldName)  
at Radzen.QueryableExtension.GetNestedPropertyExpression(Expression expression, String property, Type type)  
at Radzen.QueryableExtension.OrderBy(IQueryable source, String ordering)  
at Radzen.QueryableExtension.OrderBy[T](IQueryable`1 source, String ordering)

---

<div class="post-metadata">

**Author:** ![enchev](https://forum.radzen.com/user_avatar/forum.radzen.com/enchev/32/16_2.png) [@enchev](https://forum.radzen.com/u/enchev)\
**Post date:** [February 19, 2025, 3:52pm UTC](https://forum.radzen.com/t/issue-with-dynamic-filtering-after-upgrading-to-radzen-6-0-x/19763/52 "2025-02-19T15:52:27Z")

</div>

Ok, I saw what's going on - wrong method is picked by the compiler. Fix will be published immediately.

---

<div class="post-metadata">

**Author:** ![JustJoe](https://forum.radzen.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@JustJoe](https://forum.radzen.com/u/JustJoe)\
**Post date:** [February 19, 2025, 4:30pm UTC](https://forum.radzen.com/t/issue-with-dynamic-filtering-after-upgrading-to-radzen-6-0-x/19763/53 "2025-02-19T16:30:38Z")

</div>

Thanks. In the Northwind sample, there is no exception any more but the result is not as expected. It sorts by Region descending, but all the records that do not have a region (Region == NULL) are at the end of the grid (which would be correct if I would have only sorted by Region desc).

But the "Country" should be used to determine the sort order for those records, that do not have a Region.

`Region ?? Country desc`  
is supposed to do this (logically):

Put all records that have a Region into a new, "virtual" dataset with an extra column "Ordering" that contains the values of the "Region" property. Next, add all records that do not have a Region (Region == NULL) to that dataset as well and use the values of "Country" to fill the "Ordering" column for those. Finally, do an OrderBy Desc on the "Ordering" column. Of course this done differently internally, but it illustrates what the expected output should be.

In addition to that, in my app where I used two DateTime properties for the ordering, I now do not get a different exception:

`Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer: Warning: Unhandled exception rendering component: Index and length must refer to a location within the string. (Parameter 'length')`

---

<div class="post-metadata">

**Author:** ![enchev](https://forum.radzen.com/user_avatar/forum.radzen.com/enchev/32/16_2.png) [@enchev](https://forum.radzen.com/u/enchev)\
**Post date:** [February 19, 2025, 4:34pm UTC](https://forum.radzen.com/t/issue-with-dynamic-filtering-after-upgrading-to-radzen-6-0-x/19763/54 "2025-02-19T16:34:26Z")

</div>

Not sure what’s that exception. Any additional details?  
UPDATE: Replicated and fixed.

---

<div class="post-metadata">

**Author:** ![JustJoe](https://forum.radzen.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@JustJoe](https://forum.radzen.com/u/JustJoe)\
**Post date:** [February 20, 2025, 8:17am UTC](https://forum.radzen.com/t/issue-with-dynamic-filtering-after-upgrading-to-radzen-6-0-x/19763/55 "2025-02-20T08:17:26Z")

</div>

Confirmed. The exception is gone now, also in my app. Thanks!

However, the intial problem remains meaning that the coalescing operator does not work as espected.

DateProcessed ?? DateCreated desc

This only sorts by DateProcessed and completely ignores DateCreated. In the example that you posted in this thread, you used two sorting properties of different data types. Better try with columns of the same type.

You can e.g. use the Northwind DB as example using the "Customers" page with this code:

```auto
protected override async Task OnInitializedAsync()
        {
            customers = await NorthwindDataService.GetCustomers(new Query() { OrderBy = "i => i.Region ?? i.Country desc" });
        }

```

It will be sorted by Region desc but all records that do not have a Region are at the end which would be correct for only sorting by Region desc. But with ?? Country it should pick Country for those records, that do not have a Region in order to determine the sorting property.

Can you confirm this?

Update: When you look at the SQL in the debug output of VS, you can see that the expression gets evaludated to: ORDER BY COALESCE([p].[DateProcessed], NULL) DESC - however, it should be ORDER BY COALESCE([p].[DateProcessed], [p].[DateCreated]) DESC  
So it looks to me if the OrderBy expression is not correctly translated into SQL...

---

<div class="post-metadata">

**Author:** ![enchev](https://forum.radzen.com/user_avatar/forum.radzen.com/enchev/32/16_2.png) [@enchev](https://forum.radzen.com/u/enchev)\
**Post date:** [February 20, 2025, 8:37am UTC](https://forum.radzen.com/t/issue-with-dynamic-filtering-after-upgrading-to-radzen-6-0-x/19763/56 "2025-02-20T08:37:58Z")

</div>

> [@JustJoe](#):
>
> Can you confirm this?

I can confirm this, we will work to fix it.

UPDATE: Just released update should handle such cases.

---

<div class="post-metadata">

**Author:** ![JustJoe](https://forum.radzen.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@JustJoe](https://forum.radzen.com/u/JustJoe)\
**Post date:** [February 20, 2025, 10:51am UTC](https://forum.radzen.com/t/issue-with-dynamic-filtering-after-upgrading-to-radzen-6-0-x/19763/57 "2025-02-20T10:51:55Z")

</div>

Excellent! 👏 👏 👏 No it works as expected again!

Thanks for your super-quick help!

---

<div class="post-metadata">

**Author:** ![JustJoe](https://forum.radzen.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@JustJoe](https://forum.radzen.com/u/JustJoe)\
**Post date:** [April 24, 2025, 9:27am UTC](https://forum.radzen.com/t/issue-with-dynamic-filtering-after-upgrading-to-radzen-6-0-x/19763/58 "2025-04-24T09:27:24Z")

</div>

Looks like there is a regression to this issue. Until version 6.5.2 this was working fine for now. But since version 6.5.3 up to the latest version 6.6.0, I once again get a "System.ArgumentException" stating:

System.ArgumentException: 'NextBillingDate ?? FirstBillingDate' is not a member of type 'MyModel.Subscription' (Parameter 'propertyOrFieldName')  
at System.Linq.Expressions.Expression.PropertyOrField(Expression expression, String propertyOrFieldName)  
at Radzen.QueryableExtension.GetNestedPropertyExpression(Expression expression, String property, Type type)  
at Radzen.QueryableExtension.OrderBy(IQueryable source, String selector)  
at Radzen.QueryableExtension.OrderBy[T](IQueryable`1 source, String selector)

Seems this got messed up again. It would be nice if you could check what the actual problem is here and provide a fix. Thanks a lot!

---

<div class="post-metadata">

**Author:** ![enchev](https://forum.radzen.com/user_avatar/forum.radzen.com/enchev/32/16_2.png) [@enchev](https://forum.radzen.com/u/enchev)\
**Post date:** [April 24, 2025, 10:12am UTC](https://forum.radzen.com/t/issue-with-dynamic-filtering-after-upgrading-to-radzen-6-0-x/19763/59 "2025-04-24T10:12:42Z")

</div>

Just published update (6.6.3) that should fix this regression.

---

<div class="post-metadata">

**Author:** ![JustJoe](https://forum.radzen.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@JustJoe](https://forum.radzen.com/u/JustJoe)\
**Post date:** [April 24, 2025, 11:21am UTC](https://forum.radzen.com/t/issue-with-dynamic-filtering-after-upgrading-to-radzen-6-0-x/19763/60 "2025-04-24T11:21:57Z")

</div>

Perfect! Now it works again as before. Thanks a lot, @enchev !

[Previous page](https://forum.radzen.com/t/issue-with-dynamic-filtering-after-upgrading-to-radzen-6-0-x/19763.md?page=2)
