DoubleQuoteString() public static méthode

public static DoubleQuoteString ( string value ) : string
value string
Résultat string
        public virtual DataTable GetIndexes(string[] restrictions)
        {
            DataTable dt = new DataTable("Indexes");

            dt.Columns.Add("INDEX_CATALOG", typeof(string));
            dt.Columns.Add("INDEX_SCHEMA", typeof(string));
            dt.Columns.Add("INDEX_NAME", typeof(string));
            dt.Columns.Add("TABLE_NAME", typeof(string));
            dt.Columns.Add("UNIQUE", typeof(bool));
            dt.Columns.Add("PRIMARY", typeof(bool));
            dt.Columns.Add("TYPE", typeof(string));
            dt.Columns.Add("COMMENT", typeof(string));

            // Get the list of tables first
            int max = restrictions == null ? 4 : restrictions.Length;

            string[] tableRestrictions = new string[Math.Max(max, 4)];
            if (restrictions != null)
            {
                restrictions.CopyTo(tableRestrictions, 0);
            }
            tableRestrictions[3] = "BASE TABLE";
            DataTable tables = GetTables(tableRestrictions);

            foreach (DataRow table in tables.Rows)
            {
                string sql = String.Format("SHOW INDEX FROM `{0}`.`{1}`",
                                           MySqlHelper.DoubleQuoteString((string)table["TABLE_SCHEMA"]),
                                           MySqlHelper.DoubleQuoteString((string)table["TABLE_NAME"]));
                MySqlDataAdapter da      = new MySqlDataAdapter(sql, connection);
                DataTable        indexes = new DataTable();
                da.Fill(indexes);
                foreach (DataRow index in indexes.Rows)
                {
                    long seq_index = (long)index["SEQ_IN_INDEX"];
                    if (seq_index != 1)
                    {
                        continue;
                    }
                    if (restrictions != null && restrictions.Length == 4 &&
                        restrictions[3] != null &&
                        !index["KEY_NAME"].Equals(restrictions[3]))
                    {
                        continue;
                    }
                    DataRow row = dt.NewRow();
                    row["INDEX_CATALOG"] = null;
                    row["INDEX_SCHEMA"]  = table["TABLE_SCHEMA"];
                    row["INDEX_NAME"]    = index["KEY_NAME"];
                    row["TABLE_NAME"]    = index["TABLE"];
                    row["UNIQUE"]        = (long)index["NON_UNIQUE"] == 0;
                    row["PRIMARY"]       = index["KEY_NAME"].Equals("PRIMARY");
                    row["TYPE"]          = index["INDEX_TYPE"];
                    row["COMMENT"]       = index["COMMENT"];
                    dt.Rows.Add(row);
                }
            }

            return(dt);
        }
Exemple #2
0
        public virtual MySqlSchemaCollection GetIndexes(string[] restrictions)
        {
            MySqlSchemaCollection dt = new MySqlSchemaCollection("Indexes");

            dt.AddColumn("INDEX_CATALOG", typeof(string));
            dt.AddColumn("INDEX_SCHEMA", typeof(string));
            dt.AddColumn("INDEX_NAME", typeof(string));
            dt.AddColumn("TABLE_NAME", typeof(string));
            dt.AddColumn("UNIQUE", typeof(bool));
            dt.AddColumn("PRIMARY", typeof(bool));
            dt.AddColumn("TYPE", typeof(string));
            dt.AddColumn("COMMENT", typeof(string));

            // Get the list of tables first
            int max = restrictions?.Length ?? 4;

            string[] tableRestrictions = new string[Math.Max(max, 4)];
            restrictions?.CopyTo(tableRestrictions, 0);
            tableRestrictions[3] = "BASE TABLE";
            MySqlSchemaCollection tables = GetTables(tableRestrictions);

            foreach (MySqlSchemaRow table in tables.Rows)
            {
                string sql = String.Format("SHOW INDEX FROM `{0}`.`{1}`",
                                           MySqlHelper.DoubleQuoteString((string)table["TABLE_SCHEMA"]),
                                           MySqlHelper.DoubleQuoteString((string)table["TABLE_NAME"]));
                MySqlSchemaCollection indexes = QueryCollection("indexes", sql);

                foreach (MySqlSchemaRow index in indexes.Rows)
                {
                    long seq_index = (long)index["SEQ_IN_INDEX"];
                    if (seq_index != 1)
                    {
                        continue;
                    }
                    if (restrictions != null && restrictions.Length == 4 &&
                        restrictions[3] != null &&
                        !index["KEY_NAME"].Equals(restrictions[3]))
                    {
                        continue;
                    }
                    MySqlSchemaRow row = dt.AddRow();
                    row["INDEX_CATALOG"] = null;
                    row["INDEX_SCHEMA"]  = table["TABLE_SCHEMA"];
                    row["INDEX_NAME"]    = index["KEY_NAME"];
                    row["TABLE_NAME"]    = index["TABLE"];
                    row["UNIQUE"]        = (long)index["NON_UNIQUE"] == 0;
                    row["PRIMARY"]       = index["KEY_NAME"].Equals("PRIMARY");
                    row["TYPE"]          = index["INDEX_TYPE"];
                    row["COMMENT"]       = index["COMMENT"];
                }
            }

            return(dt);
        }
Exemple #3
0
        public virtual MySqlSchemaCollection GetIndexes(string[] restrictions)
        {
            MySqlSchemaCollection schemas = new MySqlSchemaCollection("Indexes");

            schemas.AddColumn("INDEX_CATALOG", typeof(string));
            schemas.AddColumn("INDEX_SCHEMA", typeof(string));
            schemas.AddColumn("INDEX_NAME", typeof(string));
            schemas.AddColumn("TABLE_NAME", typeof(string));
            schemas.AddColumn("UNIQUE", typeof(bool));
            schemas.AddColumn("PRIMARY", typeof(bool));
            schemas.AddColumn("TYPE", typeof(string));
            schemas.AddColumn("COMMENT", typeof(string));
            int num = (restrictions == null) ? 4 : restrictions.Length;

            string[] array = new string[Math.Max(num, 4)];
            if (restrictions != null)
            {
                restrictions.CopyTo(array, 0);
            }
            array[3] = "BASE TABLE";
            foreach (MySqlSchemaRow row in this.GetTables(array).Rows)
            {
                string sql = string.Format("SHOW INDEX FROM `{0}`.`{1}`", MySqlHelper.DoubleQuoteString((string)row["TABLE_SCHEMA"]), MySqlHelper.DoubleQuoteString((string)row["TABLE_NAME"]));
                foreach (MySqlSchemaRow row2 in this.QueryCollection("indexes", sql).Rows)
                {
                    long num2 = (long)row2["SEQ_IN_INDEX"];
                    if ((num2 == 1L) && (((restrictions == null) || (restrictions.Length != 4)) || ((restrictions[3] == null) || row2["KEY_NAME"].Equals(restrictions[3]))))
                    {
                        MySqlSchemaRow row3 = schemas.AddRow();
                        row3["INDEX_CATALOG"] = null;
                        row3["INDEX_SCHEMA"]  = row["TABLE_SCHEMA"];
                        row3["INDEX_NAME"]    = row2["KEY_NAME"];
                        row3["TABLE_NAME"]    = row2["TABLE"];
                        row3["UNIQUE"]        = ((long)row2["NON_UNIQUE"]) == 0L;
                        row3["PRIMARY"]       = row2["KEY_NAME"].Equals("PRIMARY");
                        row3["TYPE"]          = row2["INDEX_TYPE"];
                        row3["COMMENT"]       = row2["COMMENT"];
                    }
                }
            }
            return(schemas);
        }