コード例 #1
0
        static void InitDbScheme(IUtHelper utHelper, bool recreateDb = false)
        {
            JsonHelper.JsonSerialize = new NhJsonSerialize();

            NHibernateProfiler.Initialize();

            //FluentNhibernateConvertions.Conventions.Add(new Nb_ForeignKeyConstraintNameConvention());
            //DbSettingHelper.ShowSql = true;
            //DbSettingHelper.ConnString = @"Data Source=.;AttachDbFilename=|DataDirectory|\App_Data\DemoDb.mdf;Integrated Security=True;Connect Timeout=30";

            var dbName     = "DemoDb";
            var connString = string.Format(@"Data Source=.;Initial Catalog={0};Persist Security Info=True;User ID=sa;Password=zqnb_123", dbName);

            DbSettingHelper.ConnString = connString;

            var sqlScriptHelper = new SqlScriptHelper();

            if (recreateDb)
            {
                sqlScriptHelper.ReCreateDbIfExist(connString, dbName);
            }
            else
            {
                sqlScriptHelper.CreateDbIfNotExist(connString, dbName);
            }

            utHelper.SetUpNHibernate(recreateDb, typeof(Program));
            ShowSplit("Setup Done!");
            Console.WriteLine();
        }
コード例 #2
0
ファイル: UtHelper.cs プロジェクト: congzw/NbDemos
        public virtual void ReCreateDbIfExist(string dbserver, string dbname, string dbuser, string dbpassword)
        {
            SqlScriptHelper helper = new SqlScriptHelper();

            helper.ReCreateDbIfExist(dbserver, dbname, dbuser, dbpassword);
        }