示例#1
0
        protected void Application_Start(Object sender, EventArgs e)
        {
            IConfigurationSource source =
                ConfigurationSettings.GetConfig("activerecord") as IConfigurationSource;

            ActiveRecordStarter.Initialize(source, typeof(Book), typeof(Publisher));

            ActiveRecordStarter.GenerateCreationScripts("../schema.sql");
        }
示例#2
0
        public void Generate()
        {
            var currentDate = DateTime.Now.ToString("ddMMyyyy");

            var creationFile = string.Format(TestContext.CurrentContext.TestDirectory + "../../../Schemas\\schema-{0}.sql", currentDate);

            ActiveRecordStarter.GenerateCreationScripts(creationFile);

            PrependDatabaseCreation(creationFile, currentDate);
        }
示例#3
0
        public virtual void OneTimeTestInitialize()
        {
            if (!initialized)
            {
                XmlConfigurator.Configure();
                IConfigurationSource source = ConfigurationSettings.GetConfig("activerecord") as IConfigurationSource;

                ActiveRecordStarter.Initialize(Assembly.GetAssembly(typeof(User)), source);

                ActiveRecordStarter.GenerateCreationScripts("script.sql");
                initialized = true;
            }
        }
示例#4
0
        protected void Application_Start()
        {
            RegisterRoutes(RouteTable.Routes);

            //FileInfo logFile = new FileInfo(Server.MapPath("Log4Net.Config"));
            //log4net.Config.XmlConfigurator.Configure(logFile);

            XmlConfigurationSource source = new XmlConfigurationSource(Server.MapPath("~/ar.config"));

            ActiveRecordStarter.Initialize(Assembly.Load("BeechtreeTech.ARProviderExample.BLL"), source);

            ActiveRecordStarter.SetSchemaDelimiter("\n GO \n");
            ActiveRecordStarter.GenerateCreationScripts(Server.MapPath("~/BeechtreeTech.ARProviderExample.sql"));
        }
        public void Application_OnStart()
        {
            container = new WindsorContainer(new XmlInterpreter());
            // ActiveRecordStarter.CreateSchema();

            try {
                if (Context.Request.IsLocal)
                {
                    ActiveRecordStarter.GenerateCreationScripts(Context.Server.MapPath("/config/export.sql"));
                }
            }
            catch
            {
                // I'm eating this error because it's just handy, not necessary
            }
        }
        public void CompositeUserTypeNested()
        {
            ActiveRecordStarter.Initialize(GetConfigSource(), typeof(Citizen), typeof(NestedCitizen));
            Recreate();

            String fileName = null;

            try
            {
                fileName = Path.GetTempFileName();
                ActiveRecordStarter.GenerateCreationScripts(fileName);
                using (TextReader r = new StreamReader(fileName))
                {
                    string schema = r.ReadToEnd();
                    Assert.IsTrue(Regex.IsMatch(schema, @"\bfirstname\b", RegexOptions.IgnoreCase));
                    Assert.IsTrue(Regex.IsMatch(schema, @"\blastname\b", RegexOptions.IgnoreCase));
                    Assert.IsTrue(Regex.IsMatch(schema, @"\bmanufacturer_firstname\b", RegexOptions.IgnoreCase));
                    Assert.IsTrue(Regex.IsMatch(schema, @"\bmanufacturer_lastname\b", RegexOptions.IgnoreCase));
                }
            }
            finally
            {
                if (fileName != null)
                {
                    File.Delete(fileName);
                }
            }

            NestedCitizen c = new NestedCitizen();

            c.Name.Name             = new string[] { "Jonh", "Doe" };
            c.ManufacturerName.Name = new string[] { "Acme", "Inc" };

            c.Create();

            NestedCitizen loaded = NestedCitizen.Find(c.Id);

            Assert.IsNotNull(loaded);
            Assert.AreEqual("Jonh", loaded.Name.Name[0]);
            Assert.AreEqual("Doe", loaded.Name.Name[1]);
            Assert.AreEqual("Acme", loaded.ManufacturerName.Name[0]);
            Assert.AreEqual("Inc", loaded.ManufacturerName.Name[1]);
        }
示例#7
0
        /// <summary> </summary>
        public void Application_OnStart()
        {
            container = new WindsorContainer(new XmlInterpreter());

            try{
                // !Controllers.installController.is_installed() &&
                String path = Context.Server.MapPath("/config/export.sql");
                ActiveRecordStarter.GenerateCreationScripts(path);
                String export = "";
                using (StreamReader srM = new StreamReader(path)) {
                    export = srM.ReadToEnd();
                }

                String sql_prep = Context.Server.MapPath("/config/sql_prep.sql");
                String prep     = "";
                using (StreamReader srM = new StreamReader(sql_prep)) {
                    prep = srM.ReadToEnd();
                }
                using (StreamReader sr = new StreamReader(Context.Server.MapPath("/config/defaults.sql"))) {       //use the config project name.. from intall controller area
                    string        connectionSting = ConfigurationManager.ConnectionStrings[0].ConnectionString;
                    var           sfimpl          = ActiveRecordMediator.GetSessionFactoryHolder().GetSessionFactory(typeof(object));
                    IDbConnection conn            = ((ISessionFactoryImplementor)sfimpl).ConnectionProvider.GetConnection();
                    //set with a fresh data base.  Later an update script will be needed
                    SqlConnection    sqlConnection = new SqlConnection(conn.ConnectionString);
                    ServerConnection svrConnection = new ServerConnection(sqlConnection);

                    string server   = svrConnection.SqlConnectionObject.DataSource;
                    string database = svrConnection.SqlConnectionObject.Database;

                    String line = @"USE [" + database + @"] 
    GO 
    " + prep + @"
    " + export + @"
    " + sr.ReadToEnd();
                    File.WriteAllText(path, line);
                }
                if (System.Web.HttpContext.Current.Request.IsLocal)
                {
                }
            } catch { }//truth of the matter, if Request is not there then we are on the server and the export is already set
        }
示例#8
0
 public void Execute(IDocumentStore dataStore)
 {
     ActiveRecordStarter.GenerateCreationScripts("Cricket.sql");
 }
示例#9
0
 public void GenerateCreationScripts(string filePath)
 {
     ActiveRecordStarter.GenerateCreationScripts(filePath);
 }
        public void WithPrefix()
        {
            ActiveRecordStarter.Initialize(GetConfigSource(), typeof(NestedWithPrefix));
            Recreate();

            String fileName = null;

            try
            {
                fileName = Path.GetTempFileName();
                ActiveRecordStarter.GenerateCreationScripts(fileName);
                using (TextReader r = new StreamReader(fileName))
                {
                    string schema = r.ReadToEnd();
                    Assert.IsTrue(Regex.IsMatch(schema, @"\bfirst\b", RegexOptions.IgnoreCase));
                    Assert.IsTrue(Regex.IsMatch(schema, @"\blast\b", RegexOptions.IgnoreCase));
                    Assert.IsTrue(Regex.IsMatch(schema, @"\bothername_first\b", RegexOptions.IgnoreCase));
                    Assert.IsTrue(Regex.IsMatch(schema, @"\bothername_last\b", RegexOptions.IgnoreCase));
                }
            }
            finally
            {
                if (fileName != null)
                {
                    File.Delete(fileName);
                }
            }

            NestedWithPrefix.DeleteAll();

            NestedWithPrefix nested = new NestedWithPrefix();

            nested.Save();

            nested = NestedWithPrefix.Find(nested.Id);
            Assert.AreEqual(1, nested.Id);
            Assert.IsNull(nested.Self);
            Assert.IsNull(nested.Other);

            nested.Self        = new Name();
            nested.Self.First  = "John";
            nested.Self.Middle = "Mystery";
            nested.Self.Last   = "Doe";

            nested.Other        = new Name();
            nested.Other.First  = "Edward";
            nested.Other.Middle = "G";
            nested.Other.Last   = "Norton";

            nested.Save();

            nested = NestedWithPrefix.Find(nested.Id);
            Assert.IsNotNull(nested.Self);
            Assert.IsNotNull(nested.Other);
            Assert.AreEqual("John", nested.Self.First);
            Assert.AreEqual("Doe", nested.Self.Last);
            Assert.AreEqual("Mystery", nested.Self.Middle);

            Assert.AreEqual("Edward", nested.Other.First);
            Assert.AreEqual("Norton", nested.Other.Last);
            Assert.AreEqual("G", nested.Other.Middle);
        }