Пример #1
0
        protected virtual void FillResult(MySqlDataReader reader, out List <IResultRow> rows)
        {
            IReadOnlyDictionary <ITableDescriptor, IReadOnlyCollection <IColumnDescriptor> > Filters = Context.Filters;

            rows = new List <IResultRow>();
            while (reader.Read())
            {
                IResultRowInternal NewResult = new ResultRow();

                foreach (KeyValuePair <ITableDescriptor, IReadOnlyCollection <IColumnDescriptor> > Entry in Filters)
                {
                    ITableDescriptor Table = Entry.Key;
                    IEnumerable <IColumnDescriptor> ColumnFilter = Entry.Value;

                    foreach (IColumnDescriptor Column in ColumnFilter)
                    {
                        string TableName  = Table.Name;
                        string ColumnName = Column.Name;
                        string ResultName = TableName + "_" + ColumnName;

                        int Index = reader.GetOrdinal(ResultName);
                        if (reader.IsDBNull(Index))
                        {
                            continue;
                        }

                        object ConvertedValue = reader[ResultName];
                        NewResult.AddResult(Column, ConvertedValue);
                    }
                }

                rows.Add(NewResult);
            }
        }
        protected virtual void FillResult(MySqlDataReader reader, IReadOnlyCollection <IColumnDescriptor> tableStructure, out List <IResultRow> rows)
        {
            IReadOnlyCollection <IColumnDescriptor> Filters = Context.Filters;

            if (Filters.Count == 0)
            {
                IList <IColumnDescriptor> MinimalFilters = new List <IColumnDescriptor>();
                foreach (IColumnDescriptor Entry in tableStructure)
                {
                    MinimalFilters.Add(Entry);
                }

                Filters = (IReadOnlyCollection <IColumnDescriptor>)MinimalFilters;
            }

            string TableName = GetTableName();

            rows = new List <IResultRow>();

            while (reader.Read())
            {
                IResultRowInternal NewResult = new ResultRow();

                foreach (IColumnDescriptor Column in Filters)
                {
                    string ColumnName  = Column.Name;
                    int    ColumnIndex = reader.GetOrdinal(ColumnName);
                    if (!reader.IsDBNull(ColumnIndex))
                    {
                        NewResult.AddResult(Column, reader[ColumnName]);
                    }
                }

                rows.Add(NewResult);
            }
        }