Пример #1
0
        public void Fill(SqlQueryDataSet dataSet, Dictionary <CrossDataColumn, SqlQueryDataSetField> columnFieldMaps)
        {
            while (!dataSet.Eof())
            {
                var row = new CrossDataRow();
                foreach (var column in Columns.OfType <CrossDataKeyColumn>())
                {
                    var field = columnFieldMaps[column];
                    var value = field.GetValue();
                    row.AddValue(column, value);
                }

                var existsRow = Find(row);
                if (existsRow != null)
                {
                    row = existsRow;
                }
                else
                {
                    Rows.Add(row);
                }

                var i = 0;
                CrossDataGroupColumnValue columnValue = null;
                foreach (var column in Columns.OfType <CrossDataGroupColumn>())
                {
                    var field = columnFieldMaps[column];
                    var value = field.GetValue();

                    var currColumnValue = i == 0 ? column.GetValue(value) : column.GetValue(columnValue, value);
                    // row.AddValue(column, columnValue, value);
                    columnValue = currColumnValue;
                    i++;
                }

                foreach (var column in Columns.OfType <CrossDataFuncColumn>())
                {
                    var field = columnFieldMaps[column];
                    var value = field.GetValue();

                    row.AddValue(column, columnValue, value);
                }

                dataSet.Next();
            }
        }
Пример #2
0
        public void Fill(IDataReader reader)
        {
            while (reader.Read())
            {
                var row = new CrossDataRow();
                foreach (var column in Columns.OfType <CrossDataKeyColumn>())
                {
                    var value = reader.IsDBNull(column.Key) ? null : reader.GetValue(column.Key);
                    row.AddValue(column, value);
                }

                var existsRow = Find(row);
                if (existsRow != null)
                {
                    row = existsRow;
                }
                else
                {
                    Rows.Add(row);
                }

                var i = 0;
                CrossDataGroupColumnValue columnValue = null;
                foreach (var column in Columns.OfType <CrossDataGroupColumn>())
                {
                    var value = reader.IsDBNull(column.Key) ? null : reader.GetValue(column.Key);

                    var currColumnValue = i == 0 ? column.GetValue(value) : column.GetValue(columnValue, value);
                    // row.AddValue(column, columnValue, value);
                    columnValue = currColumnValue;
                    i++;
                }

                foreach (var column in Columns.OfType <CrossDataFuncColumn>())
                {
                    var value = reader.IsDBNull(column.Key) ? null : reader.GetValue(column.Key);

                    row.AddValue(column, columnValue, value);
                }
            }
        }