Beispiel #1
0
        public CrossDataRow Find(CrossDataRow aRow)
        {
            foreach (var row in Rows)
            {
                var b = true;
                foreach (var column in Columns.OfType <CrossDataKeyColumn>())
                {
                    var val1 = row.GetValue(column);
                    var val2 = aRow.GetValue(column);

                    if (val1 == null && val2 == null)
                    {
                        continue;
                    }
                    if (val1 == null || val2 == null)
                    {
                        b = false;
                        break;
                    }
                    if (val1.ValueEquals(val2))
                    {
                        continue;
                    }
                    b = false;
                    break;
                }
                if (b)
                {
                    return(row);
                }
            }
            return(null);
        }
Beispiel #2
0
 public IEnumerable <object> GetRowColumnDatas(CrossDataRow row)
 {
     return
         (ColumnItems()
          .Select(
              colItem =>
              colItem.ColumnValues != null && colItem.ColumnValues.Count > 0
                         ? row.Find(colItem.Column, colItem.ColumnValues[0])
                         : row.Find(colItem.Column))
          .Select(rowValue => rowValue != null ? rowValue.Value : null));
 }
Beispiel #3
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();
            }
        }
Beispiel #4
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);
                }
            }
        }