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

Stored Procedures Web API to grid

3 Answers 253 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bertha
Top achievements
Rank 1
Bertha asked on 10 May 2017, 12:17 AM

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

3 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 11 May 2017, 02:46 PM

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.
0
Bertha
Top achievements
Rank 1
answered on 11 May 2017, 05:17 PM

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

 

0
Boyan Dimitrov
Telerik team
answered on 15 May 2017, 11:32 AM

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.
Tags
Grid
Asked by
Bertha
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Bertha
Top achievements
Rank 1
Share this question
or