Exemple #1
0
 public override void OnDbModelConstructing(DbModel dbModel)
 {
     base.OnDbModelConstructing(dbModel);
     // it will be added to DbModel by constructor itself
     var arrAsTable = new DbCustomTypeInfo(dbModel, SystemSchema, ArrayAsTableTypeName, DbCustomTypeKind.TableType,
                                           isNullable: false, size: -1);
 }
Exemple #2
0
 public override void BuildCustomTypeDropSql(DbObjectChange change, DbCustomTypeInfo typeInfo)
 {
     // We drop only Vita_* automatic types
     if (typeInfo.Name.StartsWith("Vita_"))
     {
         change.AddScript(DbScriptType.CustomTypeDrop, $"DROP TYPE {typeInfo.FullName};");
     }
 }
Exemple #3
0
        protected virtual void LoadUserDefinedTypes()
        {
            var data = GetUserDefinedTypes();

            foreach (DbRow row in data.Rows)
            {
                var schema   = row.GetAsString("TYPE_SCHEMA");
                var name     = row.GetAsString("TYPE_NAME");
                var typeInfo = new DbCustomTypeInfo(this.Model, schema, name);
                this.Model.AddCustomType(typeInfo);
            }
        }
        public override void BuildCustomTypeAddSql(DbObjectChange change, DbCustomTypeInfo typeInfo)
        {
            var sqlCreateTemplate = "CREATE TYPE {0} AS TABLE ([Value] Sql_Variant);";
            var sqlGrantTemplate  = "Grant EXECUTE on TYPE::{0} to {1};";

            change.AddScript(DbScriptType.CustomTypeAdd, sqlCreateTemplate, typeInfo.FullName);
            if (!string.IsNullOrWhiteSpace(Settings.GrantExecReadToRole))
            {
                change.AddScript(DbScriptType.CustomTypeAdd, sqlGrantTemplate, typeInfo.FullName, Settings.GrantExecReadToRole);
            }
            if (!string.IsNullOrWhiteSpace(Settings.GrantExecWriteToRole) && Settings.GrantExecWriteToRole != Settings.GrantExecReadToRole)
            {
                change.AddScript(DbScriptType.CustomTypeAdd, sqlGrantTemplate, typeInfo.FullName, Settings.GrantExecWriteToRole);
            }
        }
Exemple #5
0
        protected virtual void LoadCustomTypes()
        {
            var data = GetCustomTypes();

            foreach (InfoRow row in data.Rows)
            {
                var schema = row.GetAsString("TYPE_SCHEMA");
                // if (!IncludeSchema(schema)) continue; -- do not filter by schema here, filter already applied in GetCustomTypes
                //   For MS SQL case, Vita_ArrayAsTable is in dbo schema (type is shared)
                var typeName   = row.GetAsString("TYPE_NAME");
                var kind       = row.GetAsInt("IS_TABLE_TYPE") == 1 ? DbCustomTypeKind.TableType : DbCustomTypeKind.Regular;
                var isNullable = row.GetAsInt("IS_NULLABLE") == 1;
                var size       = row.GetAsInt("SIZE");
                var typeInfo   = new DbCustomTypeInfo(Model, schema, typeName, kind, isNullable, size);
                //constructor adds it to Model.CustomTypes
            }
        }
Exemple #6
0
        public override void BuildCustomTypeAddSql(DbObjectChange change, DbCustomTypeInfo typeInfo)
        {
            var tn = typeInfo.FullName;

            change.AddScript(DbScriptType.CustomTypeAdd, $"CREATE TYPE {tn} AS TABLE ([Value] Sql_Variant);");
            var execReadRole = this.Settings.GetCustomSetting(MsSqlDbDriver.SettingsKeyGrantExecReadRole, "public");

            if (!string.IsNullOrWhiteSpace(execReadRole))
            {
                change.AddScript(DbScriptType.CustomTypeAdd, $"Grant EXECUTE on TYPE::{tn} to [{execReadRole}];");
            }
            var execWriteRole = this.Settings.GetCustomSetting(MsSqlDbDriver.SettingsKeyGrantExecWriteRole, "public");

            if (!string.IsNullOrWhiteSpace(execWriteRole) && execWriteRole != execReadRole)
            {
                change.AddScript(DbScriptType.CustomTypeAdd, $"Grant EXECUTE on TYPE::{tn} to [{execWriteRole}];");
            }
        }
Exemple #7
0
 public virtual void BuildCustomTypeDropSql(DbObjectChange change, DbCustomTypeInfo typeInfo)
 {
 }