本文整理汇总了C#中MySql.Data.MySqlClient.MySqlSchemaCollection类的典型用法代码示例。如果您正苦于以下问题:C# MySqlSchemaCollection类的具体用法?C# MySqlSchemaCollection怎么用?C# MySqlSchemaCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MySqlSchemaCollection类属于MySql.Data.MySqlClient命名空间,在下文中一共展示了MySqlSchemaCollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetDatabases
public virtual MySqlSchemaCollection GetDatabases(string[] restrictions)
{
Regex regex = null;
int caseSetting = Int32.Parse(connection.driver.Property("lower_case_table_names"));
string sql = "SHOW DATABASES";
// if lower_case_table_names is zero, then case lookup should be sensitive
// so we can use LIKE to do the matching.
if (caseSetting == 0)
{
if (restrictions != null && restrictions.Length >= 1)
sql = sql + " LIKE '" + restrictions[0] + "'";
}
MySqlSchemaCollection c = QueryCollection("Databases", sql);
if (caseSetting != 0 && restrictions != null && restrictions.Length >= 1 && restrictions[0] != null)
regex = new Regex(restrictions[0], RegexOptions.IgnoreCase);
MySqlSchemaCollection c2 = new MySqlSchemaCollection("Databases");
c2.AddColumn("CATALOG_NAME", typeof(string));
c2.AddColumn("SCHEMA_NAME", typeof(string));
foreach (MySqlSchemaRow row in c.Rows)
{
if (regex != null && !regex.Match(row[0].ToString()).Success) continue;
MySqlSchemaRow newRow = c2.AddRow();
newRow[1] = row[0];
}
return c2;
}
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:32,代码来源:SchemaProvider.cs
示例2: GetColumns
public virtual MySqlSchemaCollection GetColumns(string[] restrictions)
{
MySqlSchemaCollection c = new MySqlSchemaCollection("Columns");
c.AddColumn("TABLE_CATALOG", typeof(string));
c.AddColumn("TABLE_SCHEMA", typeof(string));
c.AddColumn("TABLE_NAME", typeof(string));
c.AddColumn("COLUMN_NAME", typeof(string));
c.AddColumn("ORDINAL_POSITION", typeof(ulong));
c.AddColumn("COLUMN_DEFAULT", typeof(string));
c.AddColumn("IS_NULLABLE", typeof(string));
c.AddColumn("DATA_TYPE", typeof(string));
c.AddColumn("CHARACTER_MAXIMUM_LENGTH", typeof(ulong));
c.AddColumn("CHARACTER_OCTET_LENGTH", typeof(ulong));
c.AddColumn("NUMERIC_PRECISION", typeof(ulong));
c.AddColumn("NUMERIC_SCALE", typeof(ulong));
c.AddColumn("CHARACTER_SET_NAME", typeof(string));
c.AddColumn("COLLATION_NAME", typeof(string));
c.AddColumn("COLUMN_TYPE", typeof(string));
c.AddColumn("COLUMN_KEY", typeof(string));
c.AddColumn("EXTRA", typeof(string));
c.AddColumn("PRIVILEGES", typeof(string));
c.AddColumn("COLUMN_COMMENT", typeof(string));
c.AddColumn("GENERATION_EXPRESSION", typeof(string));
// we don't allow restricting on table type here
string columnName = null;
if (restrictions != null && restrictions.Length == 4)
{
columnName = restrictions[3];
restrictions[3] = null;
}
MySqlSchemaCollection tables = GetTables(restrictions);
foreach (MySqlSchemaRow row in tables.Rows)
LoadTableColumns(c, row["TABLE_SCHEMA"].ToString(),
row["TABLE_NAME"].ToString(), columnName);
QuoteDefaultValues(c);
return c;
}
开发者ID:yalunwang,项目名称:DotnetSpider,代码行数:40,代码来源:SchemaProvider.cs
示例3: SetDSInfo
internal static void SetDSInfo(MySqlSchemaCollection sc)
{
// we use name indexing because this method will only be called
// when GetSchema is called for the DataSourceInformation
// collection and then it wil be cached.
MySqlSchemaRow row = sc.AddRow();
row["TypeName"] = "TINY INT";
row["ProviderDbType"] = MySqlDbType.UByte;
row["ColumnSize"] = 0;
row["CreateFormat"] = "TINYINT UNSIGNED";
row["CreateParameters"] = null;
row["DataType"] = "System.Byte";
row["IsAutoincrementable"] = true;
row["IsBestMatch"] = true;
row["IsCaseSensitive"] = false;
row["IsFixedLength"] = true;
row["IsFixedPrecisionScale"] = true;
row["IsLong"] = false;
row["IsNullable"] = true;
row["IsSearchable"] = true;
row["IsSearchableWithLike"] = false;
row["IsUnsigned"] = true;
row["MaximumScale"] = 0;
row["MinimumScale"] = 0;
row["IsConcurrencyType"] = DBNull.Value;
row["IsLiteralSupported"] = false;
row["LiteralPrefix"] = null;
row["LiteralSuffix"] = null;
row["NativeDataType"] = null;
}
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:30,代码来源:MySqlUByte.cs
示例4: GetForeignKeysOnTable
/// <summary>
/// GetForeignKeysOnTable retrieves the foreign keys on the given table.
/// Since MySQL supports foreign keys on versions prior to 5.0, we can't use
/// information schema. MySQL also does not include any type of SHOW command
/// for foreign keys so we have to resort to use SHOW CREATE TABLE and parsing
/// the output.
/// </summary>
/// <param name="fkTable">The table to store the key info in.</param>
/// <param name="tableToParse">The table to get the foeign key info for.</param>
/// <param name="filterName">Only get foreign keys that match this name.</param>
/// <param name="includeColumns">Should column information be included in the table.</param>
private void GetForeignKeysOnTable(MySqlSchemaCollection fkTable, MySqlSchemaRow tableToParse,
string filterName, bool includeColumns)
{
string sqlMode = GetSqlMode();
if (filterName != null)
filterName = StringUtility.ToLowerInvariant(filterName);
string sql = string.Format("SHOW CREATE TABLE `{0}`.`{1}`",
tableToParse["TABLE_SCHEMA"], tableToParse["TABLE_NAME"]);
string lowerBody = null, body = null;
MySqlCommand cmd = new MySqlCommand(sql, connection);
using (MySqlDataReader reader = cmd.ExecuteReader())
{
reader.Read();
body = reader.GetString(1);
lowerBody = StringUtility.ToLowerInvariant(body);
}
MySqlTokenizer tokenizer = new MySqlTokenizer(lowerBody);
tokenizer.AnsiQuotes = sqlMode.IndexOf("ANSI_QUOTES") != -1;
tokenizer.BackslashEscapes = sqlMode.IndexOf("NO_BACKSLASH_ESCAPES") != -1;
while (true)
{
string token = tokenizer.NextToken();
// look for a starting contraint
while (token != null && (token != "constraint" || tokenizer.Quoted))
token = tokenizer.NextToken();
if (token == null) break;
ParseConstraint(fkTable, tableToParse, tokenizer, includeColumns);
}
}
开发者ID:schivei,项目名称:mysql-connector-net,代码行数:45,代码来源:SchemaProvider.cs
示例5: FindTables
private void FindTables(MySqlSchemaCollection schema, string[] restrictions)
{
StringBuilder sql = new StringBuilder();
StringBuilder where = new StringBuilder();
sql.AppendFormat(CultureInfo.InvariantCulture,
"SHOW TABLE STATUS FROM `{0}`", restrictions[1]);
if (restrictions != null && restrictions.Length >= 3 &&
restrictions[2] != null)
where.AppendFormat(CultureInfo.InvariantCulture,
" LIKE '{0}'", restrictions[2]);
sql.Append(where.ToString());
string table_type = restrictions[1].ToLower() == "information_schema"
?
"SYSTEM VIEW"
: "BASE TABLE";
MySqlCommand cmd = new MySqlCommand(sql.ToString(), connection);
using (MySqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
MySqlSchemaRow row = schema.AddRow();
row["TABLE_CATALOG"] = null;
row["TABLE_SCHEMA"] = restrictions[1];
row["TABLE_NAME"] = reader.GetString(0);
row["TABLE_TYPE"] = table_type;
row["ENGINE"] = GetString(reader, 1);
row["VERSION"] = reader.GetValue(2);
row["ROW_FORMAT"] = GetString(reader, 3);
row["TABLE_ROWS"] = reader.GetValue(4);
row["AVG_ROW_LENGTH"] = reader.GetValue(5);
row["DATA_LENGTH"] = reader.GetValue(6);
row["MAX_DATA_LENGTH"] = reader.GetValue(7);
row["INDEX_LENGTH"] = reader.GetValue(8);
row["DATA_FREE"] = reader.GetValue(9);
row["AUTO_INCREMENT"] = reader.GetValue(10);
row["CREATE_TIME"] = reader.GetValue(11);
row["UPDATE_TIME"] = reader.GetValue(12);
row["CHECK_TIME"] = reader.GetValue(13);
row["TABLE_COLLATION"] = GetString(reader, 14);
row["CHECKSUM"] = reader.GetValue(15);
row["CREATE_OPTIONS"] = GetString(reader, 16);
row["TABLE_COMMENT"] = GetString(reader, 17);
}
}
}
开发者ID:schivei,项目名称:mysql-connector-net,代码行数:47,代码来源:SchemaProvider.cs
示例6: ParseConstraint
private static void ParseConstraint(MySqlSchemaCollection fkTable, MySqlSchemaRow table,
MySqlTokenizer tokenizer, bool includeColumns)
{
string name = tokenizer.NextToken();
MySqlSchemaRow row = fkTable.AddRow();
// make sure this constraint is a FK
string token = tokenizer.NextToken();
if (token != "foreign" || tokenizer.Quoted)
return;
tokenizer.NextToken(); // read off the 'KEY' symbol
tokenizer.NextToken(); // read off the '(' symbol
row["CONSTRAINT_CATALOG"] = table["TABLE_CATALOG"];
row["CONSTRAINT_SCHEMA"] = table["TABLE_SCHEMA"];
row["TABLE_CATALOG"] = table["TABLE_CATALOG"];
row["TABLE_SCHEMA"] = table["TABLE_SCHEMA"];
row["TABLE_NAME"] = table["TABLE_NAME"];
row["REFERENCED_TABLE_CATALOG"] = null;
row["CONSTRAINT_NAME"] = name.Trim(new char[] { '\'', '`' });
List<string> srcColumns = includeColumns ? ParseColumns(tokenizer) : null;
// now look for the references section
while (token != "references" || tokenizer.Quoted)
token = tokenizer.NextToken();
string target1 = tokenizer.NextToken();
string target2 = tokenizer.NextToken();
if (target2.StartsWith(".", StringComparison.Ordinal))
{
row["REFERENCED_TABLE_SCHEMA"] = target1;
row["REFERENCED_TABLE_NAME"] = target2.Substring(1).Trim(new char[] { '\'', '`' });
tokenizer.NextToken(); // read off the '('
}
else
{
row["REFERENCED_TABLE_SCHEMA"] = table["TABLE_SCHEMA"];
row["REFERENCED_TABLE_NAME"] = target1.Substring(1).Trim(new char[] { '\'', '`' }); ;
}
// if we are supposed to include columns, read the target columns
List<string> targetColumns = includeColumns ? ParseColumns(tokenizer) : null;
if (includeColumns)
ProcessColumns(fkTable, row, srcColumns, targetColumns);
else
fkTable.Rows.Add(row);
}
开发者ID:schivei,项目名称:mysql-connector-net,代码行数:48,代码来源:SchemaProvider.cs
示例7: GetDataTypes
private static MySqlSchemaCollection GetDataTypes()
{
MySqlSchemaCollection dt = new MySqlSchemaCollection("DataTypes");
dt.AddColumn("TypeName", typeof(string));
dt.AddColumn("ProviderDbType", typeof(int));
dt.AddColumn("ColumnSize", typeof(long));
dt.AddColumn("CreateFormat", typeof(string));
dt.AddColumn("CreateParameters", typeof(string));
dt.AddColumn("DataType", typeof(string));
dt.AddColumn("IsAutoincrementable", typeof(bool));
dt.AddColumn("IsBestMatch", typeof(bool));
dt.AddColumn("IsCaseSensitive", typeof(bool));
dt.AddColumn("IsFixedLength", typeof(bool));
dt.AddColumn("IsFixedPrecisionScale", typeof(bool));
dt.AddColumn("IsLong", typeof(bool));
dt.AddColumn("IsNullable", typeof(bool));
dt.AddColumn("IsSearchable", typeof(bool));
dt.AddColumn("IsSearchableWithLike", typeof(bool));
dt.AddColumn("IsUnsigned", typeof(bool));
dt.AddColumn("MaximumScale", typeof(short));
dt.AddColumn("MinimumScale", typeof(short));
dt.AddColumn("IsConcurrencyType", typeof(bool));
dt.AddColumn("IsLiteralSupported", typeof(bool));
dt.AddColumn("LiteralPrefix", typeof(string));
dt.AddColumn("LiteralSuffix", typeof(string));
dt.AddColumn("NativeDataType", typeof(string));
// have each one of the types contribute to the datatypes collection
MySqlBit.SetDSInfo(dt);
MySqlBinary.SetDSInfo(dt);
MySqlDateTime.SetDSInfo(dt);
MySqlTimeSpan.SetDSInfo(dt);
MySqlString.SetDSInfo(dt);
MySqlDouble.SetDSInfo(dt);
MySqlSingle.SetDSInfo(dt);
MySqlByte.SetDSInfo(dt);
MySqlInt16.SetDSInfo(dt);
MySqlInt32.SetDSInfo(dt);
MySqlInt64.SetDSInfo(dt);
MySqlDecimal.SetDSInfo(dt);
MySqlUByte.SetDSInfo(dt);
MySqlUInt16.SetDSInfo(dt);
MySqlUInt32.SetDSInfo(dt);
MySqlUInt64.SetDSInfo(dt);
return dt;
}
开发者ID:schivei,项目名称:mysql-connector-net,代码行数:47,代码来源:SchemaProvider.cs
示例8: QueryCollection
protected MySqlSchemaCollection QueryCollection(string name, string sql)
{
MySqlSchemaCollection c = new MySqlSchemaCollection(name);
MySqlCommand cmd = new MySqlCommand(sql, connection);
MySqlDataReader reader = cmd.ExecuteReader();
for (int i = 0; i < reader.FieldCount; i++)
c.AddColumn(reader.GetName(i), reader.GetFieldType(i));
using (reader)
{
while (reader.Read())
{
MySqlSchemaRow row = c.AddRow();
for (int i = 0; i < reader.FieldCount; i++)
row[i] = reader.GetValue(i);
}
}
return c;
}
开发者ID:schivei,项目名称:mysql-connector-net,代码行数:20,代码来源:SchemaProvider.cs
示例9: LoadTableColumns
private void LoadTableColumns(MySqlSchemaCollection schemaCollection, string schema,
string tableName, string columnRestriction)
{
string sql = String.Format("SHOW FULL COLUMNS FROM `{0}`.`{1}`",
schema, tableName);
MySqlCommand cmd = new MySqlCommand(sql, connection);
int pos = 1;
using (MySqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
string colName = reader.GetString(0);
if (columnRestriction != null && colName != columnRestriction)
continue;
MySqlSchemaRow row = schemaCollection.AddRow();
row["TABLE_CATALOG"] = DBNull.Value;
row["TABLE_SCHEMA"] = schema;
row["TABLE_NAME"] = tableName;
row["COLUMN_NAME"] = colName;
row["ORDINAL_POSITION"] = pos++;
row["COLUMN_DEFAULT"] = reader.GetValue(5);
row["IS_NULLABLE"] = reader.GetString(3);
row["DATA_TYPE"] = reader.GetString(1);
row["CHARACTER_MAXIMUM_LENGTH"] = DBNull.Value;
row["CHARACTER_OCTET_LENGTH"] = DBNull.Value;
row["NUMERIC_PRECISION"] = DBNull.Value;
row["NUMERIC_SCALE"] = DBNull.Value;
row["CHARACTER_SET_NAME"] = reader.GetValue(2);
row["COLLATION_NAME"] = row["CHARACTER_SET_NAME"];
row["COLUMN_TYPE"] = reader.GetString(1);
row["COLUMN_KEY"] = reader.GetString(4);
row["EXTRA"] = reader.GetString(6);
row["PRIVILEGES"] = reader.GetString(7);
row["COLUMN_COMMENT"] = reader.GetString(8);
ParseColumnRow(row);
}
}
}
开发者ID:schivei,项目名称:mysql-connector-net,代码行数:39,代码来源:SchemaProvider.cs
示例10: SetDSInfo
public static void SetDSInfo(MySqlSchemaCollection sc)
{
string[] types = new string[] { "BLOB", "TINYBLOB", "MEDIUMBLOB", "LONGBLOB", "BINARY", "VARBINARY" };
MySqlDbType[] dbtype = new MySqlDbType[] { MySqlDbType.Blob,
MySqlDbType.TinyBlob, MySqlDbType.MediumBlob, MySqlDbType.LongBlob, MySqlDbType.Binary, MySqlDbType.VarBinary };
long[] sizes = new long[] { 65535L, 255L, 16777215L, 4294967295L, 255L, 65535L };
string[] format = new string[] { null, null, null, null, "binary({0})", "varbinary({0})" };
string[] parms = new string[] { null, null, null, null, "length", "length" };
// we use name indexing because this method will only be called
// when GetSchema is called for the DataSourceInformation
// collection and then it wil be cached.
for (int x = 0; x < types.Length; x++)
{
MySqlSchemaRow row = sc.AddRow();
row["TypeName"] = types[x];
row["ProviderDbType"] = dbtype[x];
row["ColumnSize"] = sizes[x];
row["CreateFormat"] = format[x];
row["CreateParameters"] = parms[x];
row["DataType"] = "System.Byte[]";
row["IsAutoincrementable"] = false;
row["IsBestMatch"] = true;
row["IsCaseSensitive"] = false;
row["IsFixedLength"] = x < 4 ? false : true;
row["IsFixedPrecisionScale"] = false;
row["IsLong"] = sizes[x] > 255;
row["IsNullable"] = true;
row["IsSearchable"] = false;
row["IsSearchableWithLike"] = false;
row["IsUnsigned"] = DBNull.Value;
row["MaximumScale"] = DBNull.Value;
row["MinimumScale"] = DBNull.Value;
row["IsConcurrencyType"] = DBNull.Value;
row["IsLiteralSupported"] = false;
row["LiteralPrefix"] = "0x";
row["LiteralSuffix"] = DBNull.Value;
row["NativeDataType"] = DBNull.Value;
}
}
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:40,代码来源:MySqlBinary.cs
示例11: ParseProcedureBody
private void ParseProcedureBody(MySqlSchemaCollection parametersTable, string body,
MySqlSchemaRow row, string nameToRestrict)
{
List<string> modes = new List<string>(new string[3] { "IN", "OUT", "INOUT" });
string sqlMode = row["SQL_MODE"].ToString();
int pos = 1;
MySqlTokenizer tokenizer = new MySqlTokenizer(body);
tokenizer.AnsiQuotes = sqlMode.IndexOf("ANSI_QUOTES") != -1;
tokenizer.BackslashEscapes = sqlMode.IndexOf("NO_BACKSLASH_ESCAPES") == -1;
tokenizer.ReturnComments = false;
string token = tokenizer.NextToken();
// this block will scan for the opening paren while also determining
// if this routine is a function. If so, then we need to add a
// parameter row for the return parameter since it is ordinal position
// 0 and should appear first.
while (token != "(")
{
if (String.Compare(token, "FUNCTION", StringComparison.OrdinalIgnoreCase) == 0 &&
nameToRestrict == null)
{
parametersTable.AddRow();
InitParameterRow(row, parametersTable.Rows[0]);
}
token = tokenizer.NextToken();
}
token = tokenizer.NextToken(); // now move to the next token past the (
while (token != ")")
{
MySqlSchemaRow parmRow = parametersTable.NewRow();
InitParameterRow(row, parmRow);
parmRow["ORDINAL_POSITION"] = pos++;
// handle mode and name for the parameter
string mode = token.ToUpper();
if (!tokenizer.Quoted && modes.Contains(mode))
{
parmRow["PARAMETER_MODE"] = mode;
token = tokenizer.NextToken();
}
if (tokenizer.Quoted)
token = token.Substring(1, token.Length - 2);
parmRow["PARAMETER_NAME"] = token;
// now parse data type
token = ParseDataType(parmRow, tokenizer);
if (token == ",")
token = tokenizer.NextToken();
// now determine if we should include this row after all
// we need to parse it before this check so we are correctly
// positioned for the next parameter
if (nameToRestrict == null ||
String.Compare(parmRow["PARAMETER_NAME"].ToString(), nameToRestrict, StringComparison.OrdinalIgnoreCase) == 0)
parametersTable.Rows.Add(parmRow);
}
// now parse out the return parameter if there is one.
token = tokenizer.NextToken().ToUpper();
if (String.Compare(token, "RETURNS", StringComparison.OrdinalIgnoreCase) == 0)
{
MySqlSchemaRow parameterRow = parametersTable.Rows[0];
parameterRow["PARAMETER_NAME"] = "RETURN_VALUE";
ParseDataType(parameterRow, tokenizer);
}
}
开发者ID:yalunwang,项目名称:DotnetSpider,代码行数:69,代码来源:ISSchemaProvider.cs
示例12: GetParametersFromIS
private MySqlSchemaCollection GetParametersFromIS(string[] restrictions, MySqlSchemaCollection routines)
{
MySqlSchemaCollection parms = null;
if (routines == null || routines.Rows.Count == 0)
{
if (restrictions == null)
{
parms = QueryCollection("parameters", "SELECT * FROM INFORMATION_SCHEMA.PARAMETERS WHERE 1=2");
}
else
parms = GetParametersForRoutineFromIS(restrictions);
}
else foreach (MySqlSchemaRow routine in routines.Rows)
{
if (restrictions != null && restrictions.Length >= 3)
restrictions[2] = routine["ROUTINE_NAME"].ToString();
parms = GetParametersForRoutineFromIS(restrictions);
}
parms.Name = "Procedure Parameters";
return parms;
}
开发者ID:yalunwang,项目名称:DotnetSpider,代码行数:23,代码来源:ISSchemaProvider.cs
示例13: GetParametersFromShowCreate
internal void GetParametersFromShowCreate(MySqlSchemaCollection parametersTable,
string[] restrictions, MySqlSchemaCollection routines)
{
// this allows us to pass in a pre-populated routines table
// and avoid the querying for them again.
// we use this when calling a procedure or function
if (routines == null)
routines = GetSchema("procedures", restrictions);
MySqlCommand cmd = connection.CreateCommand();
foreach (MySqlSchemaRow routine in routines.Rows)
{
string showCreateSql = String.Format("SHOW CREATE {0} `{1}`.`{2}`",
routine["ROUTINE_TYPE"], routine["ROUTINE_SCHEMA"],
routine["ROUTINE_NAME"]);
cmd.CommandText = showCreateSql;
try
{
string nameToRestrict = null;
if (restrictions != null && restrictions.Length == 5 &&
restrictions[4] != null)
nameToRestrict = restrictions[4];
using (MySqlDataReader reader = cmd.ExecuteReader())
{
reader.Read();
string body = reader.GetString(2);
reader.Close();
ParseProcedureBody(parametersTable, body, routine, nameToRestrict);
}
}
catch (MySqlNullValueException snex)
{
throw new InvalidOperationException(
String.Format("Resources.UnableToRetrieveParameters", routine["ROUTINE_NAME"]), snex);
}
}
}
开发者ID:yalunwang,项目名称:DotnetSpider,代码行数:40,代码来源:ISSchemaProvider.cs
示例14: CreateParametersTable
internal MySqlSchemaCollection CreateParametersTable()
{
MySqlSchemaCollection dt = new MySqlSchemaCollection("Procedure Parameters");
dt.AddColumn("SPECIFIC_CATALOG", typeof(string));
dt.AddColumn("SPECIFIC_SCHEMA", typeof(string));
dt.AddColumn("SPECIFIC_NAME", typeof(string));
dt.AddColumn("ORDINAL_POSITION", typeof(Int32));
dt.AddColumn("PARAMETER_MODE", typeof(string));
dt.AddColumn("PARAMETER_NAME", typeof(string));
dt.AddColumn("DATA_TYPE", typeof(string));
dt.AddColumn("CHARACTER_MAXIMUM_LENGTH", typeof(Int32));
dt.AddColumn("CHARACTER_OCTET_LENGTH", typeof(Int32));
dt.AddColumn("NUMERIC_PRECISION", typeof(byte));
dt.AddColumn("NUMERIC_SCALE", typeof(Int32));
dt.AddColumn("CHARACTER_SET_NAME", typeof(string));
dt.AddColumn("COLLATION_NAME", typeof(string));
dt.AddColumn("DTD_IDENTIFIER", typeof(string));
dt.AddColumn("ROUTINE_TYPE", typeof(string));
return dt;
}
开发者ID:yalunwang,项目名称:DotnetSpider,代码行数:20,代码来源:ISSchemaProvider.cs
示例15: GetProcedureParameters
/// <summary>
/// Return schema information about parameters for procedures and functions
/// Restrictions supported are:
/// schema, name, type, parameter name
/// </summary>
public virtual MySqlSchemaCollection GetProcedureParameters(string[] restrictions,
MySqlSchemaCollection routines)
{
bool is55 = connection.driver.Version.isAtLeast(5, 5, 3);
try
{
// we want to avoid using IS if we can as it is painfully slow
MySqlSchemaCollection dt = CreateParametersTable();
GetParametersFromShowCreate(dt, restrictions, routines);
return dt;
}
catch (Exception)
{
if (!is55) throw;
// we get here by not having access and we are on 5.5 or later so just use IS
return GetParametersFromIS(restrictions, routines);
}
}
开发者ID:yalunwang,项目名称:DotnetSpider,代码行数:25,代码来源:ISSchemaProvider.cs
示例16: GetCollections
protected virtual MySqlSchemaCollection GetCollections()
{
object[][] collections = new object[][]
{
new object[] {"MetaDataCollections", 0, 0},
new object[] {"DataSourceInformation", 0, 0},
new object[] {"DataTypes", 0, 0},
new object[] {"Restrictions", 0, 0},
new object[] {"ReservedWords", 0, 0},
new object[] {"Databases", 1, 1},
new object[] {"Tables", 4, 2},
new object[] {"Columns", 4, 4},
new object[] {"Users", 1, 1},
new object[] {"Foreign Keys", 4, 3},
new object[] {"IndexColumns", 5, 4},
new object[] {"Indexes", 4, 3},
new object[] {"Foreign Key Columns", 4, 3},
new object[] {"UDF", 1, 1}
};
MySqlSchemaCollection dt = new MySqlSchemaCollection("MetaDataCollections");
dt.AddColumn("CollectionName", typeof(string));
dt.AddColumn("NumberOfRestrictions", typeof(int));
dt.AddColumn("NumberOfIdentifierParts", typeof(int));
FillTable(dt, collections);
return dt;
}
开发者ID:schivei,项目名称:mysql-connector-net,代码行数:29,代码来源:SchemaProvider.cs
示例17: GetRestrictions
protected virtual MySqlSchemaCollection GetRestrictions()
{
object[][] restrictions = new object[][]
{
new object[] {"Users", "Name", "", 0},
new object[] {"Databases", "Name", "", 0},
new object[] {"Tables", "Database", "", 0},
new object[] {"Tables", "Schema", "", 1},
new object[] {"Tables", "Table", "", 2},
new object[] {"Tables", "TableType", "", 3},
new object[] {"Columns", "Database", "", 0},
new object[] {"Columns", "Schema", "", 1},
new object[] {"Columns", "Table", "", 2},
new object[] {"Columns", "Column", "", 3},
new object[] {"Indexes", "Database", "", 0},
new object[] {"Indexes", "Schema", "", 1},
new object[] {"Indexes", "Table", "", 2},
new object[] {"Indexes", "Name", "", 3},
new object[] {"IndexColumns", "Database", "", 0},
new object[] {"IndexColumns", "Schema", "", 1},
new object[] {"IndexColumns", "Table", "", 2},
new object[] {"IndexColumns", "ConstraintName", "", 3},
new object[] {"IndexColumns", "Column", "", 4},
new object[] {"Foreign Keys", "Database", "", 0},
new object[] {"Foreign Keys", "Schema", "", 1},
new object[] {"Foreign Keys", "Table", "", 2},
new object[] {"Foreign Keys", "Constraint Name", "", 3},
new object[] {"Foreign Key Columns", "Catalog", "", 0},
new object[] {"Foreign Key Columns", "Schema", "", 1},
new object[] {"Foreign Key Columns", "Table", "", 2},
new object[] {"Foreign Key Columns", "Constraint Name", "", 3},
new object[] {"UDF", "Name", "", 0}
};
MySqlSchemaCollection dt = new MySqlSchemaCollection("Restrictions");
dt.AddColumn("CollectionName", typeof(string));
dt.AddColumn("RestrictionName", typeof(string));
dt.AddColumn("RestrictionDefault", typeof(string));
dt.AddColumn("RestrictionNumber", typeof(int));
FillTable(dt, restrictions);
return dt;
}
开发者ID:schivei,项目名称:mysql-connector-net,代码行数:44,代码来源:SchemaProvider.cs
示例18: GetForeignKeys
public virtual MySqlSchemaCollection GetForeignKeys(string[] restrictions)
{
MySqlSchemaCollection dt = new MySqlSchemaCollection("Foreign Keys");
dt.AddColumn("CONSTRAINT_CATALOG", typeof(string));
dt.AddColumn("CONSTRAINT_SCHEMA", typeof(string));
dt.AddColumn("CONSTRAINT_NAME", typeof(string));
dt.AddColumn("TABLE_CATALOG", typeof(string));
dt.AddColumn("TABLE_SCHEMA", typeof(string));
dt.AddColumn("TABLE_NAME", typeof(string));
dt.AddColumn("MATCH_OPTION", typeof(string));
dt.AddColumn("UPDATE_RULE", typeof(string));
dt.AddColumn("DELETE_RULE", typeof(string));
dt.AddColumn("REFERENCED_TABLE_CATALOG", typeof(string));
dt.AddColumn("REFERENCED_TABLE_SCHEMA", typeof(string));
dt.AddColumn("REFERENCED_TABLE_NAME", typeof(string));
// first we use our restrictions to get a list of tables that should be
// consulted. We save the keyname restriction since GetTables doesn't
// understand that.
string keyName = null;
if (restrictions != null && restrictions.Length >= 4)
{
keyName = restrictions[3];
restrictions[3] = null;
}
MySqlSchemaCollection tables = GetTables(restrictions);
// now for each table retrieved, we call our helper function to
// parse it's foreign keys
foreach (MySqlSchemaRow table in tables.Rows)
GetForeignKeysOnTable(dt, table, keyName, false);
return dt;
}
开发者ID:schivei,项目名称:mysql-connector-net,代码行数:35,代码来源:SchemaProvider.cs
示例19: QuoteDefaultValues
protected void QuoteDefaultValues(MySqlSchemaCollection schemaCollection)
{
if (schemaCollection == null) return;
if (!schemaCollection.ContainsColumn("COLUMN_DEFAULT")) return;
foreach (MySqlSchemaRow row in schemaCollection.Rows)
{
object defaultValue = row["COLUMN_DEFAULT"];
if (MetaData.IsTextType(row["DATA_TYPE"].ToString()))
row["COLUMN_DEFAULT"] = String.Format("{0}", defaultValue);
}
}
开发者ID:schivei,项目名称:mysql-connector-net,代码行数:12,代码来源:SchemaProvider.cs
示例20: GetIndexColumns
public virtual MySqlSchemaCollection GetIndexColumns(string[] restrictions)
{
MySqlSchemaCollection dt = new MySqlSchemaCollection("IndexColumns");
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("COLUMN_NAME", typeof(string));
dt.AddColumn("ORDINAL_POSITION", typeof(int));
dt.AddColumn("SORT_ORDER", typeof(string));
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";
MySqlSchemaCollection tables = GetTables(tableRestrictions);
foreach (MySqlSchemaRow table in tables.Rows)
{
string sql = String.Format("SHOW INDEX FROM `{0}`.`{1}`",
table["TABLE_SCHEMA"], table["TABLE_NAME"]);
MySqlCommand cmd = new MySqlCommand(sql, connection);
using (MySqlDataReader reade
|
请发表评论