/// <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) { var result = new DataTablesResult <TSource>(q, dataTableParam); result.Data = result.Data .Transform <TSource, Dictionary <string, object> >(row => TransformTypeInfo <TTransform> .MergeToDictionary(transform, row)) .Transform <Dictionary <string, object>, Dictionary <string, object> >(StringTransformers.TransformDictionary) .Transform <Dictionary <string, object>, object[]>(d => d.Values.ToArray()); return(result); }
/// <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); }
public static DataTablesResult <TSource> Create <TSource>(IQueryable <TSource> q, DataTablesParam dataTableParam, ArrayOutputType?arrayOutput = null) { var result = new DataTablesResult <TSource>(q, dataTableParam); result.Data = result.Data .Transform <TSource, Dictionary <string, object> >(DataTablesTypeInfo <TSource> .ToDictionary) .Transform <Dictionary <string, object>, Dictionary <string, object> >(StringTransformers.StringifyValues); result.Data = ApplyOutputRules(result.Data, arrayOutput); return(result); }
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); }