public static string GetSelectColumnSql(this ISelectProperties selectProperties, int id = 0, params string[] properties) { StringBuilder columnNames = new StringBuilder(); if (properties != null && properties.Length > 0) { foreach (var property in properties) { columnNames.Append(property + ","); } } else { var propertiesAll = selectProperties.GetType().GetProperties(); if (propertiesAll != null) { foreach (var property in propertiesAll) { if (property.IgnoreSelectProperty(selectProperties, id) || property.IsPropertyUsedByFrameWork()) { continue; } string columnName = property.GetPropertyAliasName(id); columnNames.Append(columnName + ","); } } } if (columnNames.Length > 1) { columnNames.Length = columnNames.Length - 1; } return(columnNames.ToString()); }
public static Dictionary <StatisticsType, Dictionary <string, List <StatisticsParameter> > > GetHeadersAndFooters(this ISelectProperties statisticsProperties, int id = MatchedID.Statistics) { Dictionary <StatisticsType, Dictionary <string, List <StatisticsParameter> > > result = new Dictionary <StatisticsType, Dictionary <string, List <StatisticsParameter> > >(); var propertiesAll = statisticsProperties.GetType().GetProperties(); if (propertiesAll != null) { foreach (var property in propertiesAll) { if (property == null || property.IsPropertyUsedByFrameWork()) { continue; } var statisticsAll = property.GetCustomAttributes(typeof(StatisticsAttribute), true)?.Select(w => (StatisticsAttribute)w).Where(w => w.ID == id); foreach (var statistics in statisticsAll) { if (statistics != null) { StatisticsType statisticsType = statistics.SType; string column = statistics.Column; string command = statistics.Command; var extra = statistics.CommandExtra; var sort = statistics.Sort; if (!result.ContainsKey(statisticsType)) { result.Add(statisticsType, new Dictionary <string, List <StatisticsParameter> >()); } if (result.ContainsKey(statisticsType)) { var valueKey = result[statisticsType]; var columnAliasName = property.Name; if (string.IsNullOrEmpty(column)) { column = property.Name; } if (valueKey == null || !valueKey.ContainsKey(command)) { result[statisticsType].Add(command, new List <StatisticsParameter> { new StatisticsParameter { CommandText = column + " " + extra, ColumnAliasName = columnAliasName, Sort = sort } }); } else { result[statisticsType][command].Add(new StatisticsParameter { CommandText = column + " " + extra, ColumnAliasName = columnAliasName, Sort = sort }); } } } } } } return(result); }