public static DBView CreatePolicy(DBTable t, EngineManager.DBTable.PolicyTypes type)
        {
            var policy_view = t.Policies.FirstOrDefault(x => x.Schema.Name == type.ToString().ToLower());
            if (policy_view == null)
            {
                policy_view = new DBView
                {
					Schema = t.Schema.Database.Schemas.FirstOrDefault(x => x.Name == type.ToString().ToLower()),
                    Name = t.Schema.Name + "_" + t.Name,
                    DefinitionSQL = string.Format("create view [{0}].[{1}_{2}]\r\nas\r\nselect t.id from {3} t", type.ToString().ToLower(), t.Schema.Name, t.Name, t.FullName),
                    Action = DB.DBAction.Create,
                    Owner = t,
                    OnAlreadyExists = DBObject.DBOnExists.PerformActionWithNoExistenceCheck,
                    Connection = t.Connection,
                    State = DBObject.DBObjectState.New
                };

                t.Policies.Add(policy_view);

            }
            else
            {
                DBViewManager.Refresh(policy_view);
                //MessageBox.Show("there is an existing \""  + type.ToString().ToLower() + "\" policy for this table"); 
            }

            return policy_view;
        }
 public static DBView CreateSecureView(DBTable t)
 {
     var sql = string.Format("exec engine.secure_CreateSecure '{0}', '{1}'", t.Schema.Name, t.Name);
     t.Connection.GetDataTable(sql);
     DBTableManager.Refresh(t); //refresh extensions -> secure view only!
     DBViewManager.Refresh(t.SecureView);
     return t.SecureView;
 }
Exemple #3
0
 public static void Refresh(DBObject o)
 {
     //redirect to proper manager
     if (o is DB)
     {
         DBManager.Refresh(o as DB);
     }
     else if (o is DBSchema)
     {
         DBSchemaManager.Refresh(o as DBSchema);
     }
     else if (o is DBTable)
     {
         DBTableManager.Refresh(o as DBTable);
     }
     else if (o is DBView)
     {
         DBViewManager.Refresh(o as DBView);
     }
 }