public async Task ProcessAsync(CancellationToken cancellationToken) { bool tableExists = _databaseCommander.ExecuteScalar <int>($"SELECT COUNT(1) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '{_settings.SchemaName}' AND TABLE_NAME = '{_settings.TableName}'") > 0; if (tableExists) { throw new Exception($"Table {_settings.TableNameQualified} already exists"); } DataTable dataTable = GetDataTableFromAccess(); PrependPrimaryKeyIfNeeded(dataTable); AppendAuditFieldsIfNeeded(dataTable); SetColumnsToCreate(dataTable); CreateTable(); await _databaseCommander.BuildCommand() .ForBulkCopy() .Into(_settings.TableNameQualified) .From(dataTable) .Mapping(mapping => mapping.UseAutoMap()) .ExecuteAsync(cancellationToken); }
/// <summary> /// Executes the command /// </summary> /// <param name="request">The command request</param> /// <returns>The result of the command</returns> public PaginationResult Execute(PaginationRequest request) { string sqlPagination = GetPaginationSql(request); string sqlPaginationCount = GetSqlRequestCount(request); DataTable dataTable = _databaseCommander.ExecuteSql(sqlPagination); int totalCount = _databaseCommander.ExecuteScalar <int>(sqlPaginationCount); return(new PaginationResult(dataTable, totalCount)); }
private bool IsColumnHasOnlyNull(string nullableColumn) { string sql = @"SELECT COUNT(1) FROM {0}.{1} WHERE {2} IS NOT NULL"; int count = _databaseCommander.ExecuteScalar <int>(string.Format(sql, _schemaName, _tableName, nullableColumn)); return(count == 0); }
public override TResult Execute() { return(_databaseCommander.ExecuteScalar <TResult>((ScalarRequest)CommandRequest)); }