public static DbResult DropAndRecreate() { DbResult apiResult = new DbResult(); try { SetConnectionStringInDatabaseHandler(); IConfigurationSource source = System.Configuration.ConfigurationManager.GetSection(SectionName) as IConfigurationSource; ActiveRecordStarter.Initialize(source, TypesToKeepTrackOf.ToArray()); ActiveRecordStarter.DropSchema(); ActiveRecordStarter.UpdateSchema(); apiResult.SetSuccessAsStatusInResponseFields(); } catch (Exception ex) { if (ex.Message.ToUpper().Contains("MORE THAN ONCE")) { apiResult.StatusCode = DbGlobals.SUCCESS_STATUS_CODE; apiResult.StatusDesc = "SUSPECTED DOUBLE INITIALIZE: " + ex.Message; } else { apiResult.SetFailuresAsStatusInResponseFields(ExceptionLeadString + ex.Message); } } return(apiResult); }
public static void Main() { ActiveRecordStarter.Initialize( new XmlConfigurationSource("../appconfig.xml"), typeof(Company), typeof(Client), typeof(Firm), typeof(Person)); // If you want to let AR to create the schema ActiveRecordStarter.CreateSchema(); // Common usage Client.DeleteAll(); Firm.DeleteAll(); Company.DeleteAll(); Company company = new Company("Keldor"); company.Save(); Firm firm = new Firm("Johnson & Norman"); firm.Save(); Client client = new Client("hammett", firm); client.Save(); // Dropping the schema ActiveRecordStarter.DropSchema(); }
private static void InitDatabase() { var config = ActiveRecordSectionHandler.Instance; var assemblyLibrary = Assembly.Load("FileProccesor"); ActiveRecordStarter.Initialize(assemblyLibrary, config); switch (ConfigurationManager.AppSettings["Enviroment"]) { case "Development": ActiveRecordStarter.DropSchema(); ActiveRecordStarter.CreateSchema(); break; case "Testing": ActiveRecordStarter.UpdateSchema(); break; default: break; } var callbackContext = new CallbackContext("Conectado a la Base de Datos", ActiveRecordStarter.ConfigurationSource.ToString()); var notification = new Notification(_application.Name, _notificationType.Name, DateTime.Now.Ticks.ToString(), "InitDatabase", "OK"); _growl.Notify(notification, callbackContext); }
public virtual void Drop() { try { ActiveRecordStarter.DropSchema(); } catch (Exception) { } }
public void InitDataBase() { if (!ActiveRecordStarter.IsInitialized) { IConfigurationSource source = System.Configuration.ConfigurationManager.GetSection("activerecord") as IConfigurationSource; ActiveRecordStarter.Initialize(typeof(EntityBase).Assembly, source); } ActiveRecordStarter.DropSchema(); ActiveRecordStarter.CreateSchema(); }
public void Drop() { // if (disableDrop) return; try { ActiveRecordStarter.DropSchema(); } catch (Exception) { } }
public void Terminate() { try { ActiveRecordStarter.DropSchema(); } catch (Exception) { } container.Dispose(); }
private static void InitDatabase() { var config = ActiveRecordSectionHandler.Instance; var assemblyLibrary = Assembly.Load("FileProccesor"); ActiveRecordStarter.Initialize(assemblyLibrary, config); switch (ConfigurationManager.AppSettings["Enviroment"]) { case "Development": ActiveRecordStarter.DropSchema(); ActiveRecordStarter.CreateSchema(); break; case "Testing": ActiveRecordStarter.UpdateSchema(); break; default: break; } }
internal ApiResult DropAndRecreate() { ApiResult apiResult = new ApiResult(); try { IConfigurationSource source = System.Configuration.ConfigurationManager.GetSection("activerecord") as IConfigurationSource; List <Type> typesToKeepTrackOf = GetTypesToKeepTrackOf(); ActiveRecordStarter.Initialize(source, typesToKeepTrackOf.ToArray()); ActiveRecordStarter.DropSchema(); ActiveRecordStarter.UpdateSchema(); Seed(); apiResult.SetSuccessAsStatusInResponseFields(); } catch (Exception ex) { HandleError("OnInitialize", "EXCEPTION", ex.Message); apiResult.SetFailuresAsStatusInResponseFields("FAILED TO INTIALIZE API"); } return(apiResult); }
/// <summary> /// Drops the Schema of all tables that this has originally initialized with /// </summary> public static void DropSchema() { ActiveRecordStarter.DropSchema(); }
public static void Main() { ActiveRecordStarter.Initialize( new XmlConfigurationSource("../appconfig.xml"), typeof(Blog), typeof(Post)); // If you want to let AR to create the schema ActiveRecordStarter.CreateSchema(); // Common usage Post.DeleteAll(); Blog.DeleteAll(); Blog blog = new Blog("somename"); blog.Author = "hammett"; blog.Save(); Post post = new Post(blog, "title", "contents", "castle"); post.Save(); Post.DeleteAll(); Blog.DeleteAll(); // Using Session Scope using (new SessionScope()) { blog = new Blog("somename"); blog.Author = "hammett"; blog.Save(); post = new Post(blog, "title", "contents", "castle"); post.Save(); } // Using transaction scope Post.DeleteAll(); Blog.DeleteAll(); TransactionScope transaction = new TransactionScope(); try { blog = new Blog("somename"); blog.Author = "hammett"; blog.Save(); post = new Post(blog, "title", "contents", "castle"); post.Save(); } catch (Exception ex) { transaction.VoteRollBack(); } finally { transaction.Dispose(); } ActiveRecordStarter.DropSchema(); }
private static void RecreateDatabase() { ActiveRecordStarter.DropSchema(); ActiveRecordStarter.CreateSchema(); }