We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

QueryableDataOperations Execute method is not working when paging enabled

Thread ID:





141439 Dec 11,2018 06:41 PM UTC Dec 19,2018 04:01 AM UTC ASP.NET Core 3
Tags: Grid
Asked On December 11, 2018 06:41 PM UTC

According to your KB: (https://www.syncfusion.com/kb/8434/server-side-api-for-datamanager-operations-with-iqueryable-data) we can use the method Execute of QueryableDataOperations instead of using individual methods.

The code in that page:

public ActionResult DataSource(DataManager data)
IQueryable<OrdersView> datasource = new NorthwindDataContext().OrdersViews;
            var count = datasource.AsQueryable().Count();
            var dm = QueryableDataOperations.Execute(datasource, data);
            return Json(new { result = dm, count = count });
is not working when I filter, search the grid. The count always will be the original count. And each time I do a filter or a search the count must be that of the result.

Manivannan Padmanaban [Syncfusion]
Replied On December 12, 2018 08:17 AM UTC

Hi Eduardo, 

Thanks for contacting syncfusion support. We are happy to assist you. 

Query: queryabledataoperations-execute-method-is-not-working-when-paging-enabled 
We are able to reproduce the reported issue at our end. In order to avoid the issue we need to update count after the operations performed. Please refer the below code example and sample link, 

// View page 

              .Datasource(ds => ds.URL("/Grid/DataSource").Adaptor("UrlAdaptor")) 
             .AllowSorting()    /*Sorting Enabled*/ 
             .AllowPaging()    /*Paging Enabled*/ 
             .Columns(col => 

// Controller Page 

       public ActionResult GridFeatures() 
            return View(); 
        public ActionResult DataSource(DataManager data) 
            IQueryable<OrdersView> datasource = new NorthwindDataContext().OrdersViews; 
            var count = datasource.AsQueryable().Count(); 
            var dm = QueryableDataOperations.Execute(datasource, data); 
            if (data.Where != null || data.Search != null || data.Sorted != null) 
                count = dm.Count(); 
            return Json(new { result = dm, count = count }); 

Manivannan Padmanaban. 

Replied On December 13, 2018 06:49 AM UTC

It would be a good practice for you to verify first before suggesting a supposed solution. I think this type of answers are of detriment for Syncfusion.

First: Your code snippet has errors.
public ActionResult DataSource(DataManager data) 
It should be:
public ActionResult DataSource([FromBody] DataManager data) 

Two: datasource is of type IQueryable
 IQueryable<OrdersView> datasource
then you don't need datasource.AsQueryable().Count();
It would be enough:

Three and most important: your code is not working
When I apply a filter (Excel like) the grid only shows 12 items (the same value of the Take default setup)

I have attached a video of this behavior.

Please, verify before suggesting a solution.

Eduardo Viñuela

Attachment: gridqueryableexecuteerror_1631eed3.zip

Vignesh Natarajan [Syncfusion]
Replied On December 19, 2018 04:01 AM UTC

Hi Eduardo, 
Sorry for the inconvenience caused. 
Query: “When I apply a filter (Excel like) the grid only shows 12 items (the same value of the Take default setup)” 
We have analyzed the reported issue and video demo shared. We have prepared a sample as per your suggestion and we are able to reproduce the reported issue at our end.  This is because while using individual method like performSorting , performWhereFilter we have updated the count value once the filtering and search operation is completed. Refer the below code example 
public ActionResult DataSource([FromBody]DataManager data) 
            IQueryable<OrdersView> datasource = new NorthwindDataContext().OrdersViews; 
            if (data.Where != null) // for filtering 
                datasource = QueryableDataOperations.PerformWhereFilter(datasource, data.Where, data.Where[0].Condition); 
            if (data.Sorted != null)//for sorting 
                datasource = QueryableDataOperations.PerformSorting(datasource, data.Sorted); 
            if (data.Search != null) 
                datasource = QueryableDataOperations.PerformSearching(datasource, data.Search); 
            int count = datasource.Count(); 
            if (data.Skip >= 0)//for paging 
                datasource = QueryableDataOperations.PerformSkip(datasource, data.Skip); 
            if (data.Take > 0)//for paging 
                datasource = QueryableDataOperations.PerformTake(datasource, data.Take); 
            return Json(new { result = datasource.ToList(), count = count }, JsonRequestBehavior.AllowGet); 
But while using execute method, will perform all the actions like performWhereFilter,perforSorting,performSarching,performTake due to which the dataSource is reduced to current view data (current page size). So once executing the Execute method, if we take the count it will be current page size only. So it is not possible return correct count value after filtering. To overcome this issue, you can use individual methods like performWhereFilter and return the count before performTake method. 
If you still wish to use Execute method, we suggest you to use below workaround to resolve the issue. 
public ActionResult UrlDataSource([FromBody]DataManager data) 
            IQueryable<OrdersView> datasource = new NorthwindDataContext().OrdersViews; 
            var count = datasource.Count();         
            datasource = QueryableDataOperations.Execute(datasource, dm); 
            if (data.Where != null) // to update the count value while filtering 
IQueryable<OrdersView> data = QueryableDataOperations.PerformWhereFilter(new NorthwindDataContext().OrdersViews, data.Where, data.Where[0].Condition); 
                count = data.Count(); 
            if (data.Search != null)// to update the count value while searching 
IQueryable<OrdersView> data = QueryableDataOperations.PerformSearching(new NorthwindDataContext().OrdersViews, data.Search); 
                count = data.Count(); 
            return Json(new { result = datasource, count = count });           
Please get back to us if you have further queries. 
Vignesh Natarajan   


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon