Esempio n. 1
0
        static void Main(string[] args)
        {
            string connectionString = ConnectionStrings.Get();

            MsSqlConfiguration databaseConfiguration = MsSqlConfiguration.MsSql2008.ShowSql().
                                                       ConnectionString(x => x.Is(connectionString));

            DomainDrivenDatabaseDeployer.DatabaseDeployer dd = null;
            ISessionFactory sessionFactory = new SessionFactoryBuilder(new MappingScheme(), databaseConfiguration)
                                             .Build(cfg => { dd = new DomainDrivenDatabaseDeployer.DatabaseDeployer(cfg); });

            dd.Drop();
            Console.WriteLine("Database dropped.");
            Thread.Sleep(1000);

            dd.Create();
            Console.WriteLine("Database created.");

            ISession session = sessionFactory.OpenSession();

            using (ITransaction tx = session.BeginTransaction())
            {
                dd.Seed(new List <IDataSeeder>
                {
                    new AccountSeeder(session),
                });
                tx.Commit();
            }
            session.Close();
            sessionFactory.Close();
            Console.WriteLine("Seed data added.");
            Thread.Sleep(2000);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            MsSqlConfiguration databaseConfiguration = MsSqlConfiguration.MsSql2008.ShowSql().
               ConnectionString(x => x.FromConnectionStringWithKey("Remote"));

            DomainDrivenDatabaseDeployer.DatabaseDeployer dd = null;
            ISessionFactory sessionFactory = new SessionFactoryBuilder(new MappingScheme(), databaseConfiguration)
               .Build(cfg => { dd = new DomainDrivenDatabaseDeployer.DatabaseDeployer(cfg); });

            dd.Drop();
            Console.WriteLine("Database dropped.");
            Thread.Sleep(1000);

            dd.Create();
            Console.WriteLine("Database created.");

            ISession session = sessionFactory.OpenSession();
            using (ITransaction tx = session.BeginTransaction())
            {
                dd.Seed(new List<IDataSeeder>
                            {
                                new AccountSeeder(session)
                            });
                tx.Commit();
            }
            session.Close();
            sessionFactory.Close();
            Console.WriteLine("Seed data added.");
            Thread.Sleep(2000);
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            MsSqlConfiguration databaseConfiguration = MsSqlConfiguration.MsSql2008.ShowSql().
                                                       ConnectionString(x => x.FromConnectionStringWithKey("CrudGesitonContenido.Local"));

            DomainDrivenDatabaseDeployer.DatabaseDeployer dd = null;
            ISessionFactory sessionFactory = new SessionFactoryBuilder(new MappingScheme(), databaseConfiguration)
                                             .Build(cfg => { dd = new DomainDrivenDatabaseDeployer.DatabaseDeployer(cfg); });

            dd.Drop();
            Console.WriteLine("Database dropped.");
            Thread.Sleep(1000);

            dd.Create();
            Console.WriteLine("Database created.");

            ISession session = sessionFactory.OpenSession();

            using (ITransaction tx = session.BeginTransaction())
            {
                dd.Seed(new List <IDataSeeder>
                {
                    new DepartamentoSeeder(session)
                });
                tx.Commit();
            }

            session.Close();
            sessionFactory.Close();
            Console.WriteLine("Seed data added.");
            Thread.Sleep(2000);
        }
Esempio n. 4
0
        private static void Main(string[] args)
        {
            try
            {
                string connectionString = ConnectionStrings.Get();

                MsSqlConfiguration databaseConfiguration = MsSqlConfiguration.MsSql2008.ShowSql().
                    ConnectionString(x => x.Is(connectionString));

                DomainDrivenDatabaseDeployer.DatabaseDeployer dd = null;
                ISessionFactory sessionFactory = new SessionFactoryBuilder(new MappingScheme(), databaseConfiguration)
                    .Build(cfg => { dd = new DomainDrivenDatabaseDeployer.DatabaseDeployer(cfg); });

                dd.Drop();
                Console.WriteLine("Database dropped.");
                Thread.Sleep(1000);

                dd.Create();
                Console.WriteLine("Database created.");

                ISession session = sessionFactory.OpenSession();
                using (ITransaction tx = session.BeginTransaction())
                {
                    dd.Seed(new List<IDataSeeder>
                    {
                        new UserSeeder(session),
                        new ProjectEntitySeeder(session),
                        new UserTypeEntitySeeder(session),
                        new UserHistoryEntitySeeder(session)
                    });
                    tx.Commit();
                }
                session.Close();
                sessionFactory.Close();
                Console.WriteLine("Seed data added.");
                Thread.Sleep(2000);
            }
            catch (Exception ex)
            {
                String innerMessage = (ex.InnerException != null)
                              ? ex.InnerException.Message
                              : "";
                Console.WriteLine(ex.Message);
                Console.WriteLine(innerMessage);
                string n = Console.ReadLine();
            }
        }
Esempio n. 5
0
        private static void Main(string[] args)
        {
            try
            {
                string connectionString = ConnectionStrings.Get();

                MsSqlConfiguration databaseConfiguration = MsSqlConfiguration.MsSql2008.ShowSql().
                                                           ConnectionString(x => x.Is(connectionString));

                DomainDrivenDatabaseDeployer.DatabaseDeployer dd = null;
                ISessionFactory sessionFactory = new SessionFactoryBuilder(new MappingScheme(), databaseConfiguration)
                                                 .Build(cfg => { dd = new DomainDrivenDatabaseDeployer.DatabaseDeployer(cfg); });

                dd.Drop();
                Console.WriteLine("Database dropped.");
                Thread.Sleep(1000);

                dd.Create();
                Console.WriteLine("Database created.");

                ISession session = sessionFactory.OpenSession();
                using (ITransaction tx = session.BeginTransaction())
                {
                    dd.Seed(new List <IDataSeeder>
                    {
                        new UserSeeder(session),
                        new ProjectEntitySeeder(session),
                        new UserTypeEntitySeeder(session),
                        new UserHistoryEntitySeeder(session)
                    });
                    tx.Commit();
                }
                session.Close();
                sessionFactory.Close();
                Console.WriteLine("Seed data added.");
                Thread.Sleep(2000);
            }
            catch (Exception ex)
            {
                String innerMessage = (ex.InnerException != null)
                              ? ex.InnerException.Message
                              : "";
                Console.WriteLine(ex.Message);
                Console.WriteLine(innerMessage);
                string n = Console.ReadLine();
            }
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            args = args.Select(x => x.ToLower()).ToArray();
            bool noArgs = !args.Any();

            ConnectionStringSettings connectionStringSettings = ConnectionStrings.Get();
            MsSqlConfiguration       databaseConfiguration    =
                MsSqlConfiguration.MsSql2008.ShowSql().ConnectionString(
                    x => x.Is(connectionStringSettings.ConnectionString))
                .Dialect <MsSqlAzureDialect>();

            CreateDatabaseIfNotExists(connectionStringSettings);

            DomainDrivenDatabaseDeployer.DatabaseDeployer dd = null;
            ISessionFactory sessionFactory = new SessionFactoryBuilder(new MappingScheme(), databaseConfiguration, new EntityInterceptor())
                                             .Build(cfg => { dd = new DomainDrivenDatabaseDeployer.DatabaseDeployer(cfg); });

            if (noArgs || args.Contains("drop"))
            {
                using (ISession sess = sessionFactory.OpenSession())
                {
                    using (IDbCommand cmd = sess.Connection.CreateCommand())
                    {
                        cmd.ExecuteSqlFile("dropForeignKeys.sql");
                        //cmd.ExecuteSqlFile("dropPrimaryKeys.sql");
                        cmd.ExecuteSqlFile("dropTables.sql");
                    }
                }
                dd.Drop();
                Console.WriteLine("");
                Console.WriteLine("Database dropped.");
            }

            if (noArgs || args.Contains("create"))
            {
                dd.Create();
                Console.WriteLine("");
                Console.WriteLine("Database created.");
            }
            else if (args.Contains("update"))
            {
                dd.Update();
                Console.WriteLine("");
                Console.WriteLine("Database updated.");
            }

            if (noArgs || args.Contains("seed"))
            {
                ISession session = sessionFactory.OpenSession();
                using (ITransaction tx = session.BeginTransaction())
                {
                    dd.Seed(new List <IDataSeeder>
                    {
                        //add data seeders here.
                        new UserSeeder(session)
                    });
                    tx.Commit();
                }
                session.Close();
                sessionFactory.Close();
                Console.WriteLine("");
                Console.WriteLine("Seed data added.");
            }

            Console.WriteLine("Done");
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            args = args.Select(x => x.ToLower()).ToArray();
            bool noArgs = !args.Any();

            ConnectionStringSettings connectionStringSettings = ConnectionStrings.Get();
            MsSqlConfiguration databaseConfiguration =
                MsSqlConfiguration.MsSql2008.ShowSql().ConnectionString(
                    x => x.Is(connectionStringSettings.ConnectionString))
                    .Dialect<MsSqlAzureDialect>();

            CreateDatabaseIfNotExists(connectionStringSettings);

            DomainDrivenDatabaseDeployer.DatabaseDeployer dd = null;
            ISessionFactory sessionFactory = new SessionFactoryBuilder(new MappingScheme(), databaseConfiguration, new EntityInterceptor())
                .Build(cfg => { dd = new DomainDrivenDatabaseDeployer.DatabaseDeployer(cfg); });

            if (noArgs || args.Contains("drop"))
            {
                using (ISession sess = sessionFactory.OpenSession())
                {
                    using (IDbCommand cmd = sess.Connection.CreateCommand())
                    {
                        cmd.ExecuteSqlFile("dropForeignKeys.sql");
                        //cmd.ExecuteSqlFile("dropPrimaryKeys.sql");
                        cmd.ExecuteSqlFile("dropTables.sql");
                    }
                }
                dd.Drop();
                Console.WriteLine("");
                Console.WriteLine("Database dropped.");
            }

            if (noArgs || args.Contains("create"))
            {
                dd.Create();
                Console.WriteLine("");
                Console.WriteLine("Database created.");
            }
            else if (args.Contains("update"))
            {
                dd.Update();
                Console.WriteLine("");
                Console.WriteLine("Database updated.");
            }

            if (noArgs || args.Contains("seed"))
            {
                ISession session = sessionFactory.OpenSession();
                using (ITransaction tx = session.BeginTransaction())
                {
                    dd.Seed(new List<IDataSeeder>
                                {
                                    //add data seeders here.
                                    new UserSeeder(session)
                                });
                    tx.Commit();
                }
                session.Close();
                sessionFactory.Close();
                Console.WriteLine("");
                Console.WriteLine("Seed data added.");
            }

            Console.WriteLine("Done");
        }