Filtering by Guid error on datagrid

I'm populating the datagrid using the LoadData event and Dynamic Linq:

        var queryItems = _auditLogService.Query();

        if (!string.IsNullOrEmpty(query.Filter)) {
            queryItems = queryItems.Where(query.Filter);
        }

        if (!string.IsNullOrEmpty(query.OrderBy)) {
            queryItems = queryItems.OrderBy(query.OrderBy);
        } else {
            queryItems = queryItems.OrderBy(o => o.Id);
        }

        count = queryItems.Count();

        if (query.Skip.HasValue) {
            queryItems = queryItems.Skip(query.Skip.Value);
        }

        if (query.Top.HasValue) {
            queryItems = queryItems.Take(query.Top.Value);
        }

However, the generated LoadDataArgs event parameter has incorrect filter syntax for Guids.

The generated filter for Guids is:

Id == fd9417ba-ce5c-43d1-b2a9-0048d9bec44b

However, applying that using Dynamic Linq gives the error:
System.Linq.Dynamic.Core.Exceptions.ParseException: 'No property or field 'fd9417ba' exists in type 'AuditLogDto''

If the guid starts with a number (Id == 1862fc11-e40e-41a9-84cd-03e11edd2f6f), it gives the error:
System.Linq.Dynamic.Core.Exceptions.ParseException: 'Operator '==' incompatible with operand types 'Guid' and 'UInt64''

In this case, the proper way to handle this using dynamic linq is to use this expression instead:

Id.Equals(Guid("fd9417ba-ce5c-43d1-b2a9-0048d9bec44b"))

Can you please generate proper filtering for guids or add an extension point to generate custom filtering expressions given a value and a type?
Or event better, that the datagrid was able to handle the IQueryable manipulations instead of passing that resposability to the user

Also, sorting by guid does not give error but seems to be broken too

It will be fixed in the next update!

1 Like

Fixed in Radzen.Blazor 1.1.35.

Thank you Vladimir. It works fine here.

I am using version 2.40.6 and the problem obvious still exists:

        var dynadashGetProjectSubCategoriesResult = await Dynadash.GetProjectSubCategories(new Query() { Filter = $@"i => i.ProjectId == {args.ProjectId}" });
        ProjectSubCategories = dynadashGetProjectSubCategoriesResult;

"ProjectId" is a SQL Server "uniqueidentified".

Hi @RobertE,

The original issue reported in this thread was fixed. What is your scenario? Is it a master detail or hierarchy ?

Hi @enchev, thanks for your quick response. It occurs in master/detail, hierarchy I do not use (yet). I also noticed that filtering does not work, but this is not so relevant since the Guid will not be visible in the final version.