Stored Procedures Web API to grid

4 posts, 0 answers
  1. Bertha
    Bertha avatar
    95 posts
    Member since:
    Aug 2012

    Posted 09 May 2017 Link to this post

    I got error message when I called Stored Procedures "GetCustOutstanding" from Web API and want to send data to kendo grid.  How can I fix that?  Thanks.

    Error message: "The result of a query cannot be enumerated more than once."

    IQueryable<GetCustOutstanding_Result> result = db.GetCustOutstanding().OrderBy(x=>x.NetDay).AsQueryable();

    return result.ToDataSourceResult(request.Take, request.Skip, request.Sort, request.Filter);  <=== error in this line

  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    2062 posts

    Posted 11 May 2017 Link to this post

    Hello,

    Please refer to the Grid Read Error: The Result of the Query cannot be enumerated more than once Error, where same problem is discussed and a solution is provided. 

    Regards,
    Boyan Dimitrov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Bertha
    Bertha avatar
    95 posts
    Member since:
    Aug 2012

    Posted 11 May 2017 Link to this post

    When I change the IQueryable to ToList(),  I cannot compile because it said the result does not contain a definition of ToDataSourceResult and no extension method.  What did I miss?  Thanks.

    DataSourceRequest request = JsonConvert.DeserializeObject<DataSourceRequest>(
    requestMessage.RequestUri.ParseQueryString().GetKey(0)
    );

    List<GetCustOutstanding_Result> result = db.GetCustOutstanding().OrderBy(x=>x.NetDay).ToList();

    return result.ToDataSourceResult(request.Take, request.Skip, request.Sort, request.Filter);   <=== cannot compile here

     

  4. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    2062 posts

    Posted 15 May 2017 Link to this post

    Hello Bertha,

    To use the ToDataSourceResult extension method you need to import the Kendo.Mvc.Extensions namespace. Could you please check whether this namespace is added in your controller? 

    Regards,
    Boyan Dimitrov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top