Exemplo n.º 1
0
        public override GroupTable Group(params string[] groupedColumnNames)
        {
            List <object> table            = _database.GenerateListFromTable(TableName);
            GroupTable    result           = new GroupTable();
            string        groupedTableName = "";
            List <string> columnsName      = new List <string>();

            foreach (string columnName in groupedColumnNames)
            {
                if (columnName == groupedColumnNames.Last())
                {
                    groupedTableName += columnName + "_Group";
                }
                else
                {
                    groupedTableName += columnName + "_";
                }

                columnsName.Add(columnName);
            }

            result.columnsName = columnsName;
            result._tableName  = groupedTableName;

            string typeName   = string.Format("{0}.Entity.{1}", typeof(SqlDAMEntity).Namespace, TableName);
            Type   entityType = Type.GetType(typeName);

            PropertyInfo[] properties = entityType.GetProperties();

            //Remove properties aren't grouped
            foreach (PropertyInfo property in properties)
            {
                if (!groupedColumnNames.Contains(property.Name))
                {
                    properties = properties.Where(p => p != property).ToArray();
                }
            }

            //Save all objects are grouped to DataTable
            foreach (object obj in table)
            {
                Dictionary <string, object> row = new Dictionary <string, object>();
                foreach (PropertyInfo property in properties)
                {
                    row.Add(property.Name, property.GetValue(obj));
                }
                result.AddRow(row);
            }

            return(result);
        }
Exemplo n.º 2
0
        public override GroupTable Max(string columnName, params string[] groupedColumnNames)
        {
            string[] concat = new string[groupedColumnNames.Length + 1];
            concat[0] = columnName;
            if (groupedColumnNames != null && groupedColumnNames.Length != 0)
            {
                groupedColumnNames.CopyTo(concat, 1);
            }

            GroupTable group = Group(concat);

            group.Max(columnName);
            return(group);
        }
Exemplo n.º 3
0
 public GroupTable(GroupTable groupTable)
 {
     dataTable   = groupTable.dataTable;
     columnsName = groupTable.columnsName;
     _tableName  = groupTable._tableName;
 }