Ejemplo n.º 1
0
        public static async Task <DataTablesResponse> GetDataTableResultAsync <T>(this IQueryable <T> query,
                                                                                  DataTablesModel param, bool disablePaging = false)
        {
            var dataTablesResponseData =
                await param.ToDataTablesParam().GetDataTablesResponseAsync(query, disablePaging).ConfigureAwait(false);

            dataTablesResponseData.iTotalDisplayRecords = dataTablesResponseData.iTotalRecords;
            var responseOptions = new ResponseOptions <T>()
            {
                ArrayOutputType = null
            };
            var dictionaryTransform = DataTablesTypeInfo <T> .ToDictionary(responseOptions);

            dataTablesResponseData = dataTablesResponseData.Transform <T, Dictionary <string, object> >(dictionaryTransform)
                                     .Transform <Dictionary <string, object>, Dictionary <string, object> >(StringTransformers.StringifyValues);
            dataTablesResponseData = ApplyOutputRules(dataTablesResponseData, responseOptions);
            return(dataTablesResponseData.ToDataTablesResponse());
        }
Ejemplo n.º 2
0
 public static DataTablesParam ToDataTablesParam(this DataTablesModel model)
 {
     return(new DataTablesParam
     {
         iDisplayStart = model.iDisplayStart,
         iDisplayLength = model.iDisplayLength,
         iColumns = model.iColumns,
         sSearch = model.sSearch,
         bEscapeRegex = model.bEscapeRegex,
         iSortingCols = model.iSortingCols,
         sEcho = model.sEcho,
         sColumnNames = model.sColumnNames,
         bSortable = model.bSortable,
         bSearchable = model.bSearchable,
         sSearchValues = model.sSearchValues,
         iSortCol = model.iSortCol,
         sSortDir = model.sSortDir,
         bEscapeRegexColumns = model.bEscapeRegexColumns
     });
 }