public static Dictionary <string, object> MergeToDictionary <TInput>(Func <TInput, TTransform> transformInput, TInput tInput)
        {
            var transform = transformInput(tInput);
            var dict      = DataTablesTypeInfo <TInput> .ToDictionary(tInput);

            foreach (var propertyInfo in typeof(TTransform).GetProperties())
            {
                dict[propertyInfo.Name] = propertyInfo.GetValue(transform, null);
            }
            return(dict);
        }
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);
        }
        public static ColDef[] ColDefs(this Type t)
        {
            var propInfos  = DataTablesTypeInfo.Properties(t);
            var columnList = new List <ColDef>();

            foreach (var dtpi in propInfos)
            {
                var colDef = new ColDef(dtpi.PropertyInfo.Name, dtpi.PropertyInfo.PropertyType);
                foreach (var att in dtpi.Attributes)
                {
                    att.ApplyTo(colDef, dtpi.PropertyInfo);
                }

                columnList.Add(colDef);
            }
            return(columnList.ToArray());
        }