This is a migrated thread and some comments may be shown as answers.

group a field generates error fw core

1 Answer 207 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dario
Top achievements
Rank 1
Veteran
Dario asked on 13 May 2020, 12:48 PM

I have this tag

@(Html.Kendo().Grid<Portale.Web2.Data.Entities.Contact>()
          .Name("contactGrid")
      .DataSource(dataSource => dataSource
          .Ajax()
          .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 });
          p.Info(true);
          p.Enabled(true);
      })
      .Sortable()
      .Groupable()
      .Filterable()
 
)
<script>
    function addInfo(e) {
        var statusFilter = $("#statusFilter").val();
     }
</script>

 

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);
            }
            else
            {
                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

System.InvalidOperationException
  HResult=0x80131509
  Messaggio=Processing of the LINQ expression '(GroupByShaperExpression:
KeySelector: (t.Source Type),
ElementSelector:(EntityShaperExpression:
    EntityType: Contact
    ValueBufferExpression:
        (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

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Alex Hajigeorgieva
Telerik team
answered on 18 May 2020, 10:22 AM

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:

https://www.telerik.com/forums/todatasource-throws-exception-using-ef-core-3-0-with-groups

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.
Tags
Grid
Asked by
Dario
Top achievements
Rank 1
Veteran
Answers by
Alex Hajigeorgieva
Telerik team
Share this question
or