internal static DataTableActionResult <T> Create <T>(DataTableRequestModel request, DataTableResponseModel <T> response) where T : class, new() { var result = new DataTableActionResult <T>(response); var dictionaryTransformFunc = new DataTableTypeInfoModel <T>().ToFuncDictionary(); result.Data = result .Data .Transform(dictionaryTransformFunc) .Transform <Dictionary <string, object>, Dictionary <string, object> >( StringTransformer.StringifyValues); result.Data = ApplyOutputRules(request, result.Data); return(result); }
/// <typeparam name="T"></typeparam> /// <param name="request"> </param> /// <param name="response"> /// The properties of this can be marked up with [DataTablesAttribute] to control sorting/searchability/visibility /// </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> internal static DataTableActionResult <T> Create <T>(DataTableRequestModel request, DataTableResponseModel <T> response, Func <T, object> transform) where T : class, new() { transform = transform ?? (s => s); var result = new DataTableActionResult <T>(response); result.Data = result .Data .Transform <T, Dictionary <string, object> > ( row => TransformTypeInfoHelper.MergeTransformValuesIntoDictionary(transform, row) ) .Transform <Dictionary <string, object>, Dictionary <string, object> >( StringTransformer.StringifyValues); result.Data = ApplyOutputRules(request, result.Data); return(result); }