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

OnQueryCreated problem with paging in grid

1 Answer 16 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Van Leeuwen
Top achievements
Rank 1
Van Leeuwen asked on 27 Jan 2014, 02:41 PM

Hello,

 

 

I have created a page with a grid and a filter section. The filter section has multiple AutoCompleteBoxes with InputType on Token, every time a token is added the grid gets filtered. This page works how it should work, but the grid and the AutoCompleteBoxes work with a LinqDataSource.

I have changed the datasource from the grid and the AutoCompleteBoxes to a EntityDataSource and every time I filter the grid and go to a other grid page I get this error: The LINQ expression node type 'Invoke' is not supported in LINQ to Entities.

This is how my code works:

When a token is added in a AutoCompleteBox this event get fired:

 

protected void RadAutoCompleteBoxSalesOrderNumber_Event(object sender, EventArgs e)
    {
      AutoCompleteBoxEntryCollection entries = ((RadAutoCompleteBox)sender).Entries;
      if (entries.Count != 0)
      {
        this.salesOrderNumber = entries[0].Text;
        ViewState["salesOrderNumber"] = entries[0].Text;
      }
      else
      {
        this.salesOrderNumber = null;
        ViewState["salesOrderNumber"] = null;
      }
    }


And this is the OnQueryCreated event the grid uses:

protected void EntityDataSourceGrid_QueryCreated(object sender, QueryCreatedEventArgs e)
    {
      IQueryable<vw_DeliveryLines> query = e.Query.OfType<vw_DeliveryLines>();
 
      e.Query = query.Where(GetData());
    }
 
private Expression<Func<vw_DeliveryLines, bool>> GetData()
    {
      var predicate = PredicateExtensions.True<vw_DeliveryLines>();
 
      if (!String.IsNullOrEmpty(salesOrderNumber))
        predicate = predicate.And(c => c.SODocNum.Equals(salesOrderNumber));
      if (salesOrderLineNumber > -1)
        predicate = predicate.And(c => c.SOLineNum.Equals(salesOrderLineNumber));
      if (!String.IsNullOrEmpty(deliveryNumber))
        predicate = predicate.And(c => c.DELDocNum.Equals(deliveryNumber));
      if (deliveryLineNumber > -1)
        predicate = predicate.And(c => c.DELLineNum.Equals(deliveryLineNumber));
 
      if (cardCode > -1)
        predicate = predicate.And(c => c.CardCode.Equals(cardCode));
 
      return predicate;
    }

I hope someone can help to fix my problem.

 

 

 

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 29 Jan 2014, 12:42 PM
Hello,

The question is not related to Kendo but to Entity-Framework and Linq. Same case is discussed here:

http://stackoverflow.com/questions/5284912/the-linq-expression-node-type-invoke-is-not-supported-in-linq-to-entities

Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Van Leeuwen
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or