예제 #1
0
        public override IDbCommand LIST_tabloid(DBConnection db, ETabloid list, string tabloidName = "")
        {
            MySqlCommand command = new MySqlCommand();

            string        emptyTableName = ToRealTableName(db.Application, tabloidName, false);
            string        sysTableName   = ToRealTableName(Application.SystemApp(), tabloidName, false);
            List <string> query          = new List <string>();

            if (list.Contains(ETabloid.ApplicationTables))
            {
                query.Add($"SELECT TABLE_NAME name, 'table' source FROM information_schema.TABLES WHERE TABLE_SCHEMA='{databaseName(db)}' AND TABLE_TYPE='BASE TABLE' AND TABLE_NAME LIKE '{emptyTableName.Replace("_", "\\_")}{(string.IsNullOrEmpty(tabloidName) ? "%" : "")}'");
            }
            if (list.Contains(ETabloid.SystemTables))
            {
                query.Add($"SELECT TABLE_NAME name, 'system' source FROM information_schema.TABLES WHERE TABLE_SCHEMA='{databaseName(db)}' AND TABLE_NAME LIKE '{sysTableName.Replace("_", "\\_")}{(string.IsNullOrEmpty(tabloidName) ? "%" : "")}'");
            }
            if (list.Contains(ETabloid.Views))
            {
                query.Add($"SELECT TABLE_NAME name, 'view' source FROM information_schema.VIEWS WHERE TABLE_SCHEMA='{databaseName(db)}' AND TABLE_NAME LIKE '{emptyTableName.Replace("_", "\\_")}{(string.IsNullOrEmpty(tabloidName) ? "%" : "")}'");
            }

            command.CommandText =
                string.Join(" UNION ALL ", query);

            return(command);
        }
예제 #2
0
        public override IDbCommand LIST_tabloid(DBConnection db, ETabloid list, string tabloidName = "")
        {
            SqlCommand command = new SqlCommand();

            string        emptyTableName = ToRealTableName(db.Application, tabloidName, false);
            string        sysTableName   = ToRealTableName(Application.SystemApp(), tabloidName, false);
            List <string> query          = new List <string>();

            if (list.Contains(ETabloid.ApplicationTables))
            {
                query.Add($"SELECT name, 'table' [source] FROM sys.tables WHERE name LIKE '{emptyTableName.Replace("_", "[_]")}{(string.IsNullOrEmpty(tabloidName) ? "%" : "")}'");
            }
            if (list.Contains(ETabloid.SystemTables))
            {
                query.Add($"SELECT name, 'system' [source] FROM sys.tables WHERE name LIKE '{sysTableName.Replace("_", "[_]")}{(string.IsNullOrEmpty(tabloidName) ? "%" : "")}'");
            }
            if (list.Contains(ETabloid.Views))
            {
                query.Add($"SELECT name, 'view' [source] FROM sys.views WHERE name LIKE '{emptyTableName.Replace("_", "[_]")}{(string.IsNullOrEmpty(tabloidName) ? "%" : "")}'");
            }

            command.CommandText =
                string.Join(" UNION ALL ", query);

            return(command);
        }
예제 #3
0
        public List <string> List(ETabloid list)
        {
            List <string> result = new List <string>();

            using (DBReader reader = ExecuteCommand(CommandSet.LIST_tabloid(this, list)))
            {
                while (reader.Read())
                {
                    result.Add(CommandSet.FromRealTableName(Application, (string)reader["name"]));
                }
            }

            return(result);
        }
예제 #4
0
        public bool Exists(string tabloidName, ETabloid list)
        {
            bool exists = false;

            using (DBReader reader = ExecuteCommand(CommandSet.LIST_tabloid(this, list, tabloidName)))
            {
                while (reader.Read())
                {
                    exists = true;
                    break;
                }
            }

            return(exists);
        }
예제 #5
0
 public abstract IDbCommand LIST_tabloid(DBConnection db, ETabloid list, string tabloidNameStartsWith = "");
예제 #6
0
 public static bool Contains(this ETabloid tabloid, ETabloid item)
 {
     return((tabloid & item) > 0);
 }