Пример #1
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++)
         {
             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();
     }
 }
Пример #2
0
        public void BulkInsert(ITableData data, string tableName)
        {
            var conn = DbConnectionManager.Clone();

            try
            {
                conn.Open();
                if (!DisableLogging)
                {
                    LoggingStart(LogType.Bulk);
                }
                conn.BeforeBulkInsert(tableName);
                conn.BulkInsert(data, tableName);
                conn.AfterBulkInsert(tableName);
                RowsAffected = data.RecordsAffected;
                if (!DisableLogging)
                {
                    LoggingEnd(LogType.Bulk);
                }
            }
            finally
            {
                if (!conn.LeaveOpen)
                {
                    conn.Close();
                }
            }
        }
Пример #3
0
        /* Public methods */
        public int ExecuteNonQuery()
        {
            var conn = DbConnectionManager.Clone();

            try
            {
                conn.Open();
                if (!DisableLogging)
                {
                    LoggingStart();
                }
                RowsAffected = DoSkipSql ? 0 : conn.ExecuteNonQuery(Command, Parameter);
                if (!DisableLogging)
                {
                    LoggingEnd(LogType.Rows);
                }
            }
            finally
            {
                if (!conn.LeaveOpen)
                {
                    conn.Close();
                }
            }
            return(RowsAffected ?? 0);
        }
Пример #4
0
        public object ExecuteScalar()
        {
            object result = null;
            var    conn   = DbConnectionManager.Clone();

            try
            {
                conn.Open();
                if (!DisableLogging)
                {
                    LoggingStart();
                }
                result = conn.ExecuteScalar(Command, Parameter);
                if (!DisableLogging)
                {
                    LoggingEnd();
                }
            }
            finally
            {
                if (!conn.LeaveOpen)
                {
                    conn.Close();
                }
            }
            return(result);
        }
Пример #5
0
 /* Public methods */
 public int ExecuteNonQuery()
 {
     using (var conn = DbConnectionManager.Clone()) {
         conn.Open();
         QueryStart();
         RowsAffected = DoSkipSql ? 0 : conn.ExecuteNonQuery(Command, _Parameter);//DbConnectionManager.ExecuteNonQuery(Command);
         QueryFinish(LogType.Rows);
     }
     return(RowsAffected ?? 0);
 }
Пример #6
0
 public void BulkInsert(IDataReader data, IColumnMappingCollection columnMapping, string tableName)
 {
     using (var conn = DbConnectionManager.Clone()) {
         conn.Open();
         QueryStart(LogType.Bulk);
         conn.BulkInsert(data, columnMapping, tableName);
         RowsAffected = data.RecordsAffected;
         QueryFinish(LogType.Bulk);
     }
 }
Пример #7
0
 public void BulkInsert(ITableData data, string tableName)
 {
     using (var conn = DbConnectionManager.Clone()) {
         conn.Open();
         QueryStart(LogType.Bulk);
         conn.BeforeBulkInsert();
         conn.BulkInsert(data, tableName);
         conn.AfterBulkInsert();
         RowsAffected = data.RecordsAffected;
         QueryFinish(LogType.Bulk);
     }
 }
Пример #8
0
        public object ExecuteScalar()
        {
            object result = null;

            using (var conn = DbConnectionManager.Clone()) {
                conn.Open();
                QueryStart();
                result = conn.ExecuteScalar(Command, _Parameter);
                QueryFinish();
            }
            return(result);
        }
Пример #9
0
 public void BulkUpsert(ITableData data, string tableName, List <string> keys, List <string> updateFields)
 {
     using (var conn = DbConnectionManager.Clone())
     {
         conn.Open();
         QueryStart(LogType.Bulk);
         conn.BeforeBulkUpsert();
         conn.BulkUpsert(data, tableName, keys, updateFields);
         conn.AfterBulkUpsert();
         RowsAffected = conn.rowsAffected;
         QueryFinish(LogType.Rows);
     }
 }
Пример #10
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();
            }
        }
Пример #11
0
        public void ExecuteReader()
        {
            var conn = DbConnectionManager.Clone();

            try
            {
                conn.Open();
                if (!DisableLogging)
                {
                    LoggingStart();
                }
                IDataReader reader = conn.ExecuteReader(Command, Parameter) as IDataReader;
                for (int rowNr = 0; rowNr < Limit; rowNr++)
                {
                    if (reader.Read())
                    {
                        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();
                    }
                    else
                    {
                        break;
                    }
                }
                reader.Close();
                if (!DisableLogging)
                {
                    LoggingEnd();
                }
            }
            finally
            {
                if (!conn.LeaveOpen)
                {
                    conn.Close();
                }
            }
        }
Пример #12
0
        /* Public methods */
        public int ExecuteNonQuery()
        {
            var conn = DbConnectionManager.Clone();

            try
            {
                conn.Open();
                QueryStart();
                RowsAffected = DoSkipSql ? 0 : conn.ExecuteNonQuery(Command, _Parameter);//DbConnectionManager.ExecuteNonQuery(Command);
                QueryFinish(LogType.Rows);
            }
            finally
            {
                if (!conn.LeaveOpen)
                {
                    conn.Close();
                }
            }
            return(RowsAffected ?? 0);
        }
Пример #13
0
        public object ExecuteScalar()
        {
            object result = null;
            var    conn   = DbConnectionManager.Clone();

            try
            {
                conn.Open();
                QueryStart();
                result = conn.ExecuteScalar(Command, _Parameter);
                QueryFinish();
            }
            finally
            {
                if (!conn.LeaveOpen)
                {
                    conn.Close();
                }
            }
            return(result);
        }