public ActionResult searchCostosEstimados() { var draw = Request.Form.GetValues("draw").FirstOrDefault(); var start = Request.Form.GetValues("start").FirstOrDefault(); var lenght = Request.Form.GetValues("length").FirstOrDefault(); var sortColumn = Request.Form.GetValues("columns[" + Request.Form.GetValues("order[0][column]").FirstOrDefault() + "][name]").FirstOrDefault(); var sortColumnDir = Request.Form.GetValues("order[0][dir]").FirstOrDefault(); var searchv = Request.Form.GetValues("search[value]").FirstOrDefault(); int pagesize = lenght != null?Convert.ToInt32(lenght) : 0; int skip = start != null?Convert.ToInt32(start) : 0; int totalRecords = 0; if (searchv.ToString().Equals("")) { searchv = "0"; } using (db) { var v = (from a in db.fn_PrecioSugerido(int.Parse(searchv.ToString())) select new { a.Orden, a.Concepto, a.CostoUnitario }); if (!(string.IsNullOrEmpty(sortColumn) && string.IsNullOrEmpty(sortColumnDir))) { v = v.OrderBy(sortColumn + " " + sortColumnDir); } totalRecords = v.Count(); var data = v.Skip(skip).Take(pagesize).ToList(); return(Json(new { draw = draw, recordsFiltered = totalRecords, recordsTotal = totalRecords, data = data }, JsonRequestBehavior.AllowGet)); } }