/* Public methods */ public int ExecuteNonQuery() { var conn = DbConnectionManager.CloneIfNotLeaveOpen(); 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); }
public void BulkInsert(ITableData data) { var conn = DbConnectionManager.CloneIfNotLeaveOpen(); try { conn.Open(); if (!DisableLogging) { LoggingStart(LogType.Bulk); } conn.BulkInsert(data); RowsAffected = data.RecordsAffected; if (!DisableLogging) { LoggingEnd(LogType.Bulk); } } finally { if (!conn.LeaveOpen) { conn.Close(); } } }
public object ExecuteScalar() { object result = null; var conn = DbConnectionManager.CloneIfNotLeaveOpen(); try { conn.Open(); if (!DisableLogging) { LoggingStart(); } result = conn.ExecuteScalar(Command, Parameter); if (!DisableLogging) { LoggingEnd(); } } finally { if (!conn.LeaveOpen) { conn.Close(); } } return(result); }
public void ExecuteReader() { var conn = DbConnectionManager.CloneIfNotLeaveOpen(); try { conn.Open(); if (!DisableLogging) { LoggingStart(); } using (var reader = conn.ExecuteReader(Command, Parameter)) { object value; for (int rowIndex = 0; rowIndex < Limit; rowIndex++) { if (reader.Read()) { BeforeRowReadAction?.Invoke(); for (int columnIndex = 0; columnIndex < Actions?.Count; columnIndex++) { value = reader.IsDBNull(columnIndex) ? null : reader.GetValue(columnIndex); Actions?[columnIndex]?.Invoke(value); } AfterRowReadAction?.Invoke(); } else { break; } } } if (!DisableLogging) { LoggingEnd(); } } finally { if (!conn.LeaveOpen) { conn.Close(); } } }