Error when Sorting on Complex Type

I'm doing some sort in a Complex Type, on a Grid

The Grid is bonded  using Field string like "Escritorio.Descrição" ( I followed the example at https://blazor.syncfusion.com/documentation/datagrid/columns/#complex-data-binding)

and it's working fine, except when I try to sort the complex field


The data is brought by a Custom DataAdaptorComponent, so at the server side, the sorting is fired ( calling 

DataOperations.PerformSorting(registrosdm.Sorted);

)

And so far so good, but when the Iqueryable is enumarated, executing the query I get the following error:

System.InvalidOperationException: The LINQ expression 'DbSet<Usuario>()

    .Select((a, i) => new {

        a = a,

        TempData = __ToList_0.get_Item(i)

     })' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.

   at Microsoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)

   at Microsoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)

   at Microsoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)

   at Microsoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)

   at Microsoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)

   at Microsoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor.Expand(Expression query)

   at Microsoft.EntityFrameworkCore.Query.QueryTranslationPreprocessor.Process(Expression query)

   at Microsoft.EntityFrameworkCore.Query.RelationalQueryTranslationPreprocessor.Process(Expression query)

   at Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutor[TResult](Expression query)

   at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](Expression query, Boolean async)

   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async)

   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass9_0`1.<Execute>b__0()

   at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)

   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)

   at NCPC.Web.Controllers.ApiController`2.Listar(DataManagerRequest dm) in C:\Projetos\NCPC\NCPC.Web\Controllers\ApiController.cs:line 42

   at lambda_method3(Closure , Object , Object[] )

   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()

   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()

--- End of stack trace from previous location ---

   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()

--- End of stack trace from previous location ---

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)

   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)

   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)

   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)

   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)

   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)


1 Reply

RS Renjith Singh Rajendran Syncfusion Team August 11, 2021 03:37 AM UTC

Hi Daniel, 

Greetings from Syncfusion support. 

We have analyzed the reported problem, and we are not clear about the exact scenario you are facing this reported problem. We need the following details to further proceed on this scenario. Kindly share with us the following details for better assistance. 

  1. Share with us a simple issue reproducing sample for us to validate. This would be helpful for us to validate based on your scenario.
  2. Share the complete Grid model class codes, and also share the complex type model class codes.
  3. Share the complete Grid rendering codes and the complete Custom DataAdaptorComponent’s Read/ReadAsync codes.
  4. Share the details of the type of DataSource you are returning from Read/ReadAsync method.
  5. Share a video demo showing the replication of the problem you are facing.
  6. Are you facing this exception when calling PerformSorting method?

The provided information will help us analyze the problem, and provide you a solution as early as possible. 

Regards, 
Renjith R 


Loader.
Up arrow icon