private void UpdateDatabase() { using (var ctx = new BonoboGitServerContext()) { IObjectContextAdapter ctxAdapter = ctx; foreach (var item in UpdateScriptRepository.GetScriptsBySqlProviderName(ctx.Database.Connection.GetType().Name)) { if (!string.IsNullOrEmpty(item.Precondition)) { try { var preConditionResult = ctxAdapter.ObjectContext.ExecuteStoreQuery <int>(item.Precondition).Single(); if (preConditionResult == 0) { continue; } } catch (Exception) { // consider failures in pre-conditions as an indication that // store ecommand should be executed } } ctxAdapter.ObjectContext.ExecuteStoreCommand(item.Command); } } }
private void DoUpdate(BonoboGitServerContext ctx) { IObjectContextAdapter ctxAdapter = ctx; var connectiontype = ctx.Database.Connection.GetType().Name; foreach (var item in UpdateScriptRepository.GetScriptsBySqlProviderName(connectiontype)) { if (!string.IsNullOrEmpty(item.Precondition)) { try { var preConditionResult = ctxAdapter.ObjectContext.ExecuteStoreQuery <int>(item.Precondition).Single(); if (preConditionResult == 0) { continue; } } catch (Exception) { // consider failures in pre-conditions as an indication that // store ecommand should be executed } } try { ctxAdapter.ObjectContext.ExecuteStoreCommand(item.Command); } catch (Exception ex) { Trace.TraceError("Exception while processing upgrade script {0}\r\n{1}", item.Command, ex); throw; } } // the current pattern does not cut it anymore for adding the guid column if (connectiontype.Equals("SQLiteConnection")) { new Sqlite.AddGuidColumn(ctx); } else { new SqlServer.AddGuidColumn(ctx); } }
private void UpdateDatabase() { using (var ctx = new BonoboGitServerContext()) { IObjectContextAdapter ctxAdapter = ctx; foreach (var item in UpdateScriptRepository.GetScriptsBySqlProviderName(ctx.Database.Connection.GetType().Name)) { if (!string.IsNullOrEmpty(item.Precondition)) { var preConditionResult = ctxAdapter.ObjectContext.ExecuteStoreQuery <int>(item.Precondition).Single(); if (preConditionResult == 0) { continue; } } ctxAdapter.ObjectContext.ExecuteStoreCommand(item.Command); } } }
private void DoUpdate(BonoboGitServerContext ctx) { IObjectContextAdapter ctxAdapter = ctx; var connectiontype = ctx.Database.Connection.GetType().Name; foreach (var item in UpdateScriptRepository.GetScriptsBySqlProviderName(connectiontype)) { if (!string.IsNullOrEmpty(item.Precondition)) { try { var preConditionResult = ctxAdapter.ObjectContext.ExecuteStoreQuery <int>(item.Precondition).Single(); if (preConditionResult == 0) { continue; } } catch (Exception) { // consider failures in pre-conditions as an indication that // store ecommand should be executed } } if (!string.IsNullOrEmpty(item.Command)) { try { ctxAdapter.ObjectContext.ExecuteStoreCommand(item.Command); } catch (Exception ex) { Trace.TraceError("Exception while processing upgrade script {0}\r\n{1}", item.Command, ex); throw; } } item.CodeAction(ctx); } }
private void DoUpdate(BonoboGitServerContext ctx, IAuthenticationProvider authenticationProvider) { foreach (var item in UpdateScriptRepository.GetScriptsBySqlProviderName(ctx.Database.ProviderName, authenticationProvider)) { if (!string.IsNullOrEmpty(item.Precondition)) { try { var preConditionResult = Convert.ToInt32(ctx.Database.ExecuteScalar(item.Precondition)); if (preConditionResult == 0) { continue; } } catch (Exception e) { // consider failures in pre-conditions as an indication that // store ecommand should be executed } } if (!string.IsNullOrEmpty(item.Command)) { try { ctx.Database.ExecuteSqlCommand(item.Command); } catch (Exception ex) { Log.Error(ex, "Exception while processing upgrade script {0}", item.Command); throw; } } item.CodeAction(ctx); } }