Beispiel #1
0
        /// <typeparam name="TSource"></typeparam>
        /// <typeparam name="TTransform"></typeparam>
        /// <param name="q">A queryable for the data. The properties of this can be marked up with [DataTablesAttribute] to control sorting/searchability/visibility</param>
        /// <param name="dataTableParam"></param>
        /// <param name="transform">//a transform for custom column rendering e.g. to do a custom date row => new { CreatedDate = row.CreatedDate.ToString("dd MM yy") } </param>
        /// <returns></returns>
        public static DataTablesResult <TSource> Create <TSource, TTransform>(IQueryable <TSource> q, DataTablesParam dataTableParam,
                                                                              Func <TSource, TTransform> transform, ResponseOptions <TSource> responseOptions = null)
        {
            var result = new DataTablesResult <TSource>(q, dataTableParam);

            result.Data = result.Data
                          .Transform <TSource, Dictionary <string, object> >(row => TransformTypeInfo.MergeTransformValuesIntoDictionary(transform, row))
                          .Transform <Dictionary <string, object>, Dictionary <string, object> >(StringTransformers.StringifyValues);

            result.Data = ApplyOutputRules(result.Data, responseOptions);

            return(result);
        }
Beispiel #2
0
        public static DataTablesResult <TSource> Create <TSource>(IQueryable <TSource> q, DataTablesParam dataTableParam,
                                                                  ResponseOptions <TSource> responseOptions = null)
        {
            var result = new DataTablesResult <TSource>(q, dataTableParam);

            var dictionaryTransform = DataTablesTypeInfo <TSource> .ToDictionary(responseOptions);

            result.Data = result.Data
                          .Transform <TSource, Dictionary <string, object> >(dictionaryTransform)
                          .Transform <Dictionary <string, object>, Dictionary <string, object> >(StringTransformers.StringifyValues);

            result.Data = ApplyOutputRules(result.Data, responseOptions);

            return(result);
        }