Esempio n. 1
0
        public static DataTablesResult Create(object queryable, DataTablesParam dataTableParam)
        {
            queryable = ((IEnumerable)queryable).AsQueryable();
            var s = "Create";

            var openCreateMethod =
                typeof(DataTablesResult).GetMethods().Single(x => x.Name == s && x.GetGenericArguments().Count() == 1);
            var queryableType      = queryable.GetType().GetGenericArguments()[0];
            var closedCreateMethod = openCreateMethod.MakeGenericMethod(queryableType);

            return((DataTablesResult)closedCreateMethod.Invoke(null, new[] { queryable, dataTableParam }));
        }
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            DataTablesParam obj     = new DataTablesParam();
            var             request = controllerContext.HttpContext.Request.Params;

            if (request.AllKeys.Contains("iDisplayStart") &&
                request.AllKeys.Contains("iDisplayLength") &&
                request.AllKeys.Contains("iColumns") &&
                request.AllKeys.Contains("iSortingCols") &&
                request.AllKeys.Contains("sEcho"))
            {
                if (dataTablesModelBinder == null)
                {
                    dataTablesModelBinder = new DataTablesModelBinder();
                }
                return(dataTablesModelBinder.BindModel(controllerContext, bindingContext));
            }
            else
            {
                return(null);
            }
        }
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            DataTablesParam obj     = new DataTablesParam();
            var             request = controllerContext.HttpContext.Request.Params;

            obj.iDisplayStart  = Convert.ToInt32(request["iDisplayStart"]);
            obj.iDisplayLength = Convert.ToInt32(request["iDisplayLength"]);
            obj.iColumns       = Convert.ToInt32(request["iColumns"]);
            obj.sSearch        = request["sSearch"];
            obj.bEscapeRegex   = Convert.ToBoolean(request["bEscapeRegex"]);
            obj.iSortingCols   = Convert.ToInt32(request["iSortingCols"]);
            obj.sEcho          = int.Parse(request["sEcho"]);

            for (int i = 0; i < obj.iColumns; i++)
            {
                obj.bSortable.Add(Convert.ToBoolean(request["bSortable_" + i]));
                obj.bSearchable.Add(Convert.ToBoolean(request["bSearchable_" + i]));
                obj.sSearchColumns.Add(request["sSearch_" + i]);
                obj.bEscapeRegexColumns.Add(Convert.ToBoolean(request["bEscapeRegex_" + i]));
                obj.iSortCol.Add(Convert.ToInt32(request["iSortCol_" + i]));
                obj.sSortDir.Add(request["sSortDir_" + i]);
            }
            return(obj);
        }
Esempio n. 4
0
 public static DataTablesResult <T> CreateResultUsingEnumerable <T>(IEnumerable <T> q, DataTablesParam dataTableParam)
 {
     return(new DataTablesResult <T, T>(q.AsQueryable(), dataTableParam, null, t => t));
 }
Esempio n. 5
0
 public static DataTablesResult <T> Create <T>(IQueryable <T> q, DataTablesParam dataTableParam)
 {
     return(new DataTablesResult <T, T>(q, dataTableParam, null, t => t));
 }
Esempio n. 6
0
 public static DataTablesResult <TRes> Create <T, TRes>(IQueryable <T> q, DataTablesParam dataTableParam, DataTablesOptions dataTableOptions, Func <T, TRes> transform)
 {
     return(new DataTablesResult <T, TRes>(q, dataTableParam, dataTableOptions, transform));
 }