Esempio n. 1
0
 public void ExecuteReader()
 {
     using (var conn = DbConnectionManager.Clone()) {
         conn.Open();
         QueryStart();
         IDataReader reader = conn.ExecuteReader(Command) as IDataReader;
         for (int rowNr = 0; rowNr < ReadTopX; rowNr++)
         {
             if (reader.Read())
             {
                 InternalBeforeRowReadAction?.Invoke();
                 BeforeRowReadAction?.Invoke();
                 for (int i = 0; i < Actions?.Count; i++)
                 {
                     if (!reader.IsDBNull(i))
                     {
                         Actions?[i]?.Invoke(reader.GetValue(i));
                     }
                     else
                     {
                         Actions?[i]?.Invoke(null);
                     }
                 }
                 AfterRowReadAction?.Invoke();
                 InternalAfterRowReadAction?.Invoke();
             }
             else
             {
                 break;
             }
         }
         reader.Close();
         QueryFinish();
     }
 }
Esempio n. 2
0
        public void ExecuteReader()
        {
            using (var conn = DbConnectionManager.Clone())
            {
                conn.Open();
                QueryStart();
                IDataReader reader = conn.ExecuteReader(Command, _Parameter) as IDataReader;
                //for (int rowNr = 0; rowNr < ReadTopX; rowNr++)
                //{
                while (reader.Read())
                {
                    InternalBeforeRowReadAction?.Invoke();
                    BeforeRowReadAction?.Invoke();
                    for (int i = 0; i < Actions?.Count; i++)
                    {
                        //if (!reader.IsDBNull(i))
                        //{
                        //string value = reader.GetValue(i).ToString();
                        //for (int j = 0; j < reader.FieldCount; j++)
                        //{
                        //    if (String.IsNullOrEmpty(value))
                        //    {
                        //        value = reader.GetValue(j).ToString();
                        //    }
                        //    else
                        //    {
                        //        value += "," + reader.GetValue(j).ToString();
                        //    }

                        //}

                        Actions?[i]?.Invoke(reader);
                        //}
                        //else
                        //{
                        //    Actions?[i]?.Invoke(null);
                        //}
                    }
                    AfterRowReadAction?.Invoke();
                    InternalAfterRowReadAction?.Invoke();
                }
                //else
                //{
                //    break;
                //}
                //}
                reader.Close();
                QueryFinish();
            }
        }