# Blazor: Query Builder changes Lambda to String

**URL:** <https://forum.radzen.com/t/blazor-query-builder-changes-lambda-to-string/1319>\
**Category:** Uncategorized\
**Created:** [July 11, 2019, 12:42pm UTC](https://forum.radzen.com/t/blazor-query-builder-changes-lambda-to-string/1319 "2019-07-11T12:42:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![joshbooker](https://forum.radzen.com/user_avatar/forum.radzen.com/joshbooker/32/12624_2.png) [@joshbooker](https://forum.radzen.com/u/joshbooker)\
**Post date:** [July 11, 2019, 12:42pm UTC](https://forum.radzen.com/t/blazor-query-builder-changes-lambda-to-string/1319/1 "2019-07-11T12:42:26Z")

</div>

Using the Query Builder to add a sort parameter causes the meta filter value to become an array.  
This appears to cause a string to be generated instead of the Lambda expression.

 ![image](https://forum.radzen.com/uploads/default/original/2X/b/b0dba8fe059f4a7452f5f5ed0090df184c7ad4ad.png)

Come to think of it, is server-side sorting even possible with the current Blazor implementation?

TIA,  
Josh

---

<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:** [July 11, 2019, 12:45pm UTC](https://forum.radzen.com/t/blazor-query-builder-changes-lambda-to-string/1319/2 "2019-07-11T12:45:10Z")

</div>

Thanks for the report Josh, we will fix that in the next release (before the end of the week). Yes, server-side paging, filtering and sorting is possible, all you need to do is to assign IQueryable to Data property.

---

<div class="post-metadata">

**Author:** ![joshbooker](https://forum.radzen.com/user_avatar/forum.radzen.com/joshbooker/32/12624_2.png) [@joshbooker](https://forum.radzen.com/u/joshbooker)\
**Post date:** [July 11, 2019, 1:42pm UTC](https://forum.radzen.com/t/blazor-query-builder-changes-lambda-to-string/1319/3 "2019-07-11T13:42:16Z")

</div>

Thanks @enchev. Could you briefly describe how best to make the Data property IQueryable in the Designer? I'm trying to affect the default sort of a ListBox. The ListBox data of dependent on the RowSelect of a DataGrid.

Probably going about this the wrong way, but the only way I can find to do this is like so:

```
${result.value}.AsQueryable().OrderByDescending(i => i.RunDate)

```

 ![image](https://forum.radzen.com/uploads/default/original/2X/d/d33b6dbd9db884be3fdaf82af7a69a1ad9e06de4.png)

But you cannot enter `IQueryable<JobDate>` property type in the drop down so I have to edit the meta file.

Is there a reason you're returning IEnumerable from the DataService instead of IQueryable? Seems the latter would be more powerful and performant for SQL Server anyway.

Thanks,  
Josh

---

<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:** [July 11, 2019, 3:13pm UTC](https://forum.radzen.com/t/blazor-query-builder-changes-lambda-to-string/1319/4 "2019-07-11T15:13:14Z")

</div>

Hi Josh,

We plan to add $orderby paramater similar to $filter where you can apply desired order similar to Angular projects:

 ![image](https://forum.radzen.com/uploads/default/original/2X/9/94b059f7588713bca544c6fda6e93bf11ea1f3a7.png)

---

<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:** [July 12, 2019, 4:05pm UTC](https://forum.radzen.com/t/blazor-query-builder-changes-lambda-to-string/1319/5 "2019-07-12T16:05:24Z")

</div>

Hi Josh,

We've just released update with enabled sorting and filtering for Blazor projects using query builder. To simplify the code we've used dynamic Linq (if you wonder why the expressions are strings):

 ![image](https://forum.radzen.com/uploads/default/original/2X/1/1b5dec03b46d115307b6304e90ed14ed7697f796.png)

```auto
...
protected async void Load()
{
     someProperty = 2;

     var sampleGetOrdersResult = await Sample.GetOrders($@"i => i.Id >= 3 && i.UserName.Contains(""{someProperty}"")", "UserName desc,Id asc");
     getOrdersResult = sampleGetOrdersResult;
}
...

```

All operations will be applied server-side:

 ![image](https://forum.radzen.com/uploads/default/original/2X/8/8033ad9b0cc6d22364b7b67738b32c9e6a002220.png)

The service also will return IQueryable instead IEnumerable if you want to add additional expressions.

Best Regards,  
Vladimir

---

<div class="post-metadata">

**Author:** ![joshbooker](https://forum.radzen.com/user_avatar/forum.radzen.com/joshbooker/32/12624_2.png) [@joshbooker](https://forum.radzen.com/u/joshbooker)\
**Post date:** [July 12, 2019, 4:57pm UTC](https://forum.radzen.com/t/blazor-query-builder-changes-lambda-to-string/1319/6 "2019-07-12T16:57:47Z")

</div>

@enchev, That's so cool! I tried for years to get MSFT to implement Dynamic Linq Library in LightSwitch. Passing expressions as text is so much easier. Hmmm I wonder if we can do plain text like:  
.Where("Id = 3 OR UserName = "%SomeProperty%"")

Thanks for the quick response. Now if only RadZen had the ability to [model querys on entities in the dataservice.](http://forum.radzen.com/t/migration-from-lightswitch/126/13?u=joshbooker)

---

<div class="post-metadata">

**Author:** ![joshbooker](https://forum.radzen.com/user_avatar/forum.radzen.com/joshbooker/32/12624_2.png) [@joshbooker](https://forum.radzen.com/u/joshbooker)\
**Post date:** [July 12, 2019, 5:30pm UTC](https://forum.radzen.com/t/blazor-query-builder-changes-lambda-to-string/1319/7 "2019-07-12T17:30:45Z")

</div>

Guys, again, thank you, this is great! Might be my imagination but I think it's much faster performance with IQueryable. PS... Had to infer from database again to get it to regen the dataservice, but that's expected behavior I think. Or perhaps the fact that I had DataService.cs in ignore list prevented upgrade(?)

---

<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:** [July 12, 2019, 6:26pm UTC](https://forum.radzen.com/t/blazor-query-builder-changes-lambda-to-string/1319/8 "2019-07-12T18:26:24Z")

</div>

Hi Josh,

Glad you liked the update - indeed should be much faster now!

If the service was ignored this will prevent Radzen to generate the new code. Yes, you can use strings to set expressions for sorting and filtering. You can use string.Format, template strings, etc.

More improvements are coming!

Best Regards,  
Vladimir
