Exemple #1
0
        public string GetCreateScript()
        {
            if (!DwarfContext <T> .IsConfigured())
            {
                throw new InvalidOperationException("Assembly must be initialized first");
            }

            return(SqlServerDatabaseScriptHelper.GetCreateScript <T>());
        }
Exemple #2
0
        public string GetTransferScript(string otherDatabaseName, params ExpressionProperty[] toSkip)
        {
            if (!DwarfContext <T> .IsConfigured())
            {
                throw new InvalidOperationException("Assembly must be initialized first");
            }

            return(SqlServerDatabaseScriptHelper.GetTransferScript <T>(otherDatabaseName, toSkip));
        }
Exemple #3
0
        public void ExecuteDropScript()
        {
            if (!DwarfContext <T> .IsConfigured())
            {
                throw new InvalidOperationException("Assembly must be initialized first");
            }

            SqlServerDatabaseScriptHelper.ExecuteDropScript <T>();
        }
        private static IEnumerable <string> GetCreateScriptArray <T>()
        {
            var scripts = SqlServerDatabaseScriptHelper.GetCreateScript <T>();
            var center  = scripts.IndexOf("ALTER");

            var tables = scripts.Substring(0, center - 1).Split(new[] { "CREATE" }, StringSplitOptions.RemoveEmptyEntries);
            var alters = scripts.Substring(center, (scripts.Length - 1 - center)).Split(new[] { "ALTER" }, StringSplitOptions.RemoveEmptyEntries);

            for (var i = 0; i < tables.Length; i++)
            {
                tables[i] = SqlCeDatabase.PurifyScriptQuery("CREATE" + tables[i]);
            }

            for (var i = 0; i < alters.Length; i++)
            {
                alters[i] = SqlCeDatabase.PurifyScriptQuery("ALTER" + alters[i]);
            }

            return(tables.ToList().Union(alters).ToArray());
        }