public Result CreateDbTable() { try { var dbConnectionRequest = new DbConnectionRequested(); OnDbConnectionRequested(dbConnectionRequest); if (dbConnectionRequest.Connection != null) { if (dbConnectionRequest.Connection.State != ConnectionState.Open) { dbConnectionRequest.Connection.Open(); } var cmd = dbConnectionRequest.Connection.CreateCommand(); cmd.CommandText = GetQuery(); cmd.ExecuteNonQuery(); var result = Result.Success(String.Format("Tworzenie tabeli: {0} zakończone sukcesem.", _table.Name)); var dbTableCreatedEventArgs = new DbTableCreatedEventArgs(_table.Name, result); OnTableCreated(dbTableCreatedEventArgs); if (dbTableCreatedEventArgs.ExternalOperationResults.IsSuccess) { return dbTableCreatedEventArgs.ExternalOperationResults.MergeFailures(); } return result; } return Result.Failure("Nie udało się pobrać połączenia do bazy danych"); } catch (Exception ex) { _logger.Error(ex, "Exception while creating table '{0}'", _table.Name); return Result.Failure(String.Format("Błąd w czasie tworzenia tabeli: {0}.", _table.Name), ex); } }
private void OnDbConnectionRequested(DbConnectionRequested dbConnectionRequested) { var dbConnReq = DbConnectionRequested; if (dbConnReq != null) { dbConnReq(this, dbConnectionRequested); } }