示例#1
0
            private static Tuple <T0, T1, T2> ReadEntity <T0, T1, T2>(this DBDataReader reader,
                                                                      DatabaseTable table0, DatabaseTable table1, DatabaseTable table2)
                where T0 : class, new()
                where T1 : class, new()
                where T2 : class, new()
            {
                if (!reader.Read())
                {
                    return(null);
                }

                var entity = new Tuple <T0, T1, T2>(new T0(), new T1(), new T2());

                var index = 0;

                foreach (var col in table0.Columns)
                {
                    col.SetValue(entity.Item1, reader[index++]);
                }

                foreach (var col in table1.Columns)
                {
                    col.SetValue(entity.Item2, reader[index++]);
                }

                foreach (var col in table2.Columns)
                {
                    col.SetValue(entity.Item3, reader[index++]);
                }

                return(entity);
            }
        public virtual void ExecuteReader()
        {
            SetUpProviderAndConnection();

            using (DBConnection)
            {
                DBCommand             = DBConnection.CreateCommand();
                DBCommand.CommandText = QueryString != null?QueryString:"Select * from State";
                DBCommand.CommandType = CommandType.Text;

                try
                {
                    //Open Connection
                    DBConnection.Open();
                    //Execute Reader
                    DBDataReader = DBCommand.ExecuteReader();

                    //SE: update this with something usable
                    var retList = new List <string>();

                    while (DBDataReader.Read())
                    {
                        retList.Add(DBDataReader[0].ToString());
                    }
                }
                catch (Exception ex)
                {
                    LogWrapper.Log(ex.Message);
                }
            }
        }
示例#3
0
        /// <summary>
        /// Get the Next response values
        /// </summary>
        /// <returns></returns>
        public List <DataMessageObject> GetNext()
        {
            try
            {
                if (DBDataReader.Read())
                {
                    string ColTime = Colums.FirstOrDefault(col => col.Value.ConceptType == ConceptTypeEnum.Dimension && ((IDimensionConcept)col.Value).DimensionType == DimensionTypeEnum.Time).Key;
                    string TimeVal = DBDataReader[ColTime].ToString();

                    Dictionary <string, object> Vals = new Dictionary <string, object>();
                    foreach (string col in Colums.Keys)
                    {
                        if (Colums[col] != null && Colums[col].ConceptType == ConceptTypeEnum.Dimension && ((IDimensionConcept)Colums[col]).DimensionType == DimensionTypeEnum.Frequency && ((IDimensionConcept)Colums[col]).IsFakeFrequency)
                        {
                            Vals[col] = (TimePeriodDBFormat.GetFrequencyValueFromTime(TimeVal));
                        }
                        else if (Colums[col] != null && Colums[col].ConceptObjectCode == FlyConfiguration.Time_Format_Id && isFakeTimeFormat)
                        {
                            Vals[col] = (TimePeriodDBFormat.GetTimeFormatValueFromTime(TimeVal));
                        }
                        else if (Colums[col] != null && Colums[col].ConceptType == ConceptTypeEnum.Dimension && ((IDimensionConcept)Colums[col]).DimensionType == DimensionTypeEnum.Time)
                        {
                            Vals[col] = (TimePeriodDBFormat.ParseTimeVal(DBDataReader[col]));
                        }
                        else
                        {
                            Vals[col] = (DBDataReader[col]);
                        }
                    }

                    List <DataMessageObject> dmo = new List <DataMessageObject>();
                    Colums.Keys.ToList().ForEach(col => dmo.Add(new DataMessageObject()
                    {
                        ColId   = col,
                        ColImpl = Colums[col],
                        Val     = Vals[col]
                    }));

                    RowsCounter++;
                    return(dmo);
                }
                return(null);
            }
            catch (Exception ex)
            {
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.DBErrorResponse, ex);
            }
        }
        public List <string> ExecuteQuery(DbConnection dbConnection)
        {
            if (dbConnection == null)
            {
                string message = "DBConnection cannot be null for using this method";
                LogginExceptionHandling.LogWrapper.Log(message);
                throw new ArgumentNullException("dbConnection", message);
            }

            if (String.IsNullOrEmpty(QueryString))
            {
                string message = "ConnectionStringName cannot be null for using this method";
                LogginExceptionHandling.LogWrapper.Log(message);
                throw new ArgumentNullException("ConnectionStringName", message);
            }

            using (dbConnection)
            {
                DBCommand             = dbConnection.CreateCommand();
                DBCommand.CommandText = QueryString;
                DBCommand.CommandType = CommandType.Text;

                try
                {
                    dbConnection.Open();
                    DBDataReader = DBCommand.ExecuteReader();
                    var retList = new List <string>();
                    while (DBDataReader.Read())
                    {
                        retList.Add(DBDataReader[0].ToString());
                    }
                    return(retList);
                }
                catch (Exception ex)
                {
                    LogginExceptionHandling.LogWrapper.Log(ex.Message);
                }
            }

            return(null);
        }
示例#5
0
            private static T ReadEntity <T>(this DBDataReader reader, DatabaseTable table)
                where T : class, new()
            {
                if (!reader.Read())
                {
                    return(null);
                }

                var entity = new T();

                do
                {
                    var index = 0;
                    foreach (var col in table.Columns)
                    {
                        col.SetValue(entity, reader[index++]);
                    }
                } while ((table = table.SuperTable) != null);

                return(entity);
            }