[controller] public async Task<ActionResult> DataSourceAsync(DataManager dm) { Task<int> longRunningTask = LongRunningOperationAsync(); int delay = await longRunningTask; DataResult result = new DataResult(); DataOperations operation = new DataOperations(); var DataSource = from a in new NorthwindDataContext().OrdersViews select a; result.result = DataSource; result.count = DataSource.Count(); if (dm.Search != null && dm.Search.Count > 0) //searching { result.result = operation.PerformSearching(DataSource, dm.Search); } if (dm.Where != null && dm.Where.Count > 0) //Filtering { result.result = operation.PerformWhereFilter(DataSource, dm.Where, dm.Where[0].Operator); } if (dm.Skip > 0) result.result = operation.PerformSkip(result.result, dm.Skip); if (dm.Take > 0) result.result = operation.PerformTake(result.result, dm.Take); return Json(dm.RequiresCounts ? (object)result : (object)result.result, JsonRequestBehavior.AllowGet); } public async Task<int> LongRunningOperationAsync() { await Task.Delay(1000); //1 seconds delay return 1; } |