コード例 #1
0
        public static void Function(this IExecuteExpressionRoot execute, string functionName)
        {
            if (string.IsNullOrWhiteSpace(functionName))
            {
                throw new Exception($"Function name can't be null or empty");
            }

            var preScriptFunction = BasicScriptsResources.PreFunctionScript.Replace("#SCRIPT_NAME#", functionName);

            var rm     = FunctionResources.ResourceManager;
            var script = rm.GetString(functionName);

            if (string.IsNullOrWhiteSpace(script))
            {
                throw new Exception(
                          $"Function \"{functionName}\" not found in {FunctionResources.ResourceManager.BaseName}");
            }

            var finalScript = string.Concat(preScriptFunction, script);

            execute.Sql(finalScript);
        }
コード例 #2
0
ファイル: Extensions.cs プロジェクト: rijuntun/vocadb
 public static void SqlFormat(this IExecuteExpressionRoot execute, string format, params object[] args)
 {
     execute.Sql(string.Format(format, args));
 }
コード例 #3
0
 public static void DropTableIfExists(this IExecuteExpressionRoot execute, string tableName)
 {
     execute.Sql(string.Format("IF (EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '{0}')) BEGIN DROP TABLE [{0}] END", tableName));
 }
コード例 #4
0
 public static void DropViewIfExists(this IExecuteExpressionRoot execute, string viewName)
 {
     execute.Sql(string.Format("IF EXISTS(select * FROM sys.views where name = '{0}') DROP VIEW [{0}]", viewName));
 }
コード例 #5
0
ファイル: DbUtility.cs プロジェクト: MoisesBas/Tawjeeh
 public static void DropViewsIfExists(this IExecuteExpressionRoot execute, string views)
 {
     execute.Sql(string.Format("IF (EXISTS (SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = '{0}')) BEGIN DROP VIEW [{0}] END", views));
 }
コード例 #6
0
ファイル: DbUtility.cs プロジェクト: MoisesBas/Tawjeeh
 public static void DropSPIfExists(this IExecuteExpressionRoot execute, string sp)
 {
     execute.Sql(string.Format("IF (EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = '{0}')) BEGIN DROP PROCEDURE [{0}] END", sp));
 }