group a field generates error fw core

2 posts, 1 answers
  1. Dario
    Dario avatar
    40 posts
    Member since:
    Jun 2018

    Posted 13 May 2020 Link to this post

    I have this tag

          .DataSource(dataSource => dataSource
              .Read(read => read.Action("GetContacts", "Contacts").Data("addInfo"))
          .Columns(columns =>
              columns.Bound(product => product.Date).Format("{0:dd/MM/yyyy}");
              columns.Bound(product => product.Name);
              columns.Bound(product => product.City);
              columns.Bound(product => product.SouceType);
              columns.Bound(product => product.Type);
              columns.Bound(product => product.Status);
              columns.Command(command => command.Custom("Completa").Visible("isNew").Click("completeContact"));
          .Pageable(p =>
              p.PageSizes(new[] { 5, 10, 30 });
        function addInfo(e) {
            var statusFilter = $("#statusFilter").val();


    I call this action


    public ActionResult GetContacts([DataSourceRequest]DataSourceRequest request, string status = "")
                if (status != "")
                    var contacts = from rec in _context.Contacts
                                   where rec.Status == status.ToContactStatus()
                                   select rec;
                    DataSourceResult result = contacts.ToDataSourceResult(request);
                    return Json(result);
                    var contacts = from rec in _context.Contacts
                                   select rec;
                    DataSourceResult result = contacts.ToDataSourceResult(request);
                    return Json(result);


    If I try to set a group, it shows me this exception

      Messaggio=Processing of the LINQ expression '(GroupByShaperExpression:
    KeySelector: (t.Source Type),
        EntityType: Contact
            (ProjectionBindingExpression: EmptyProjectionMember)
        IsNullable: False
    )' by 'RelationalProjectionBindingExpressionVisitor' failed. This may indicate either a bug or a limitation in EF Core.


    I'm using a EF Core 3.1.4 that it connects to SQL Server 2018


  2. Answer
    Alex Hajigeorgieva
    Alex Hajigeorgieva avatar
    1082 posts

    Posted 18 May 2020 Link to this post

    Hi, Dario,

    This is a known breaking change that Microsoft introduces with EF 3.1 and one of the solutions is to call ToList() before calling the ToDataSourceResult() or ToDataSourceResultAsync() extension methods.

    You can read more about it in this forum thread:

    Kind Regards,
    Alex Hajigeorgieva
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
Back to Top