Beispiel #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);
        }
Beispiel #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);
        }