本文整理汇总了C#中FirebirdSql.Data.FirebirdClient.FbConnection.GetSchema方法的典型用法代码示例。如果您正苦于以下问题:C# FbConnection.GetSchema方法的具体用法?C# FbConnection.GetSchema怎么用?C# FbConnection.GetSchema使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FirebirdSql.Data.FirebirdClient.FbConnection
的用法示例。
在下文中一共展示了FbConnection.GetSchema方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildCommand
protected FbCommand BuildCommand(FbConnection connection, string collectionName, string[] restrictions)
{
string filter = String.Format("CollectionName='{0}'", collectionName);
StringBuilder builder = this.GetCommandText(restrictions);
DataRow[] restriction = connection.GetSchema(DbMetaDataCollectionNames.Restrictions).Select(filter);
FbTransaction transaction = connection.InnerConnection.ActiveTransaction;
FbCommand command = new FbCommand(builder.ToString(), connection, transaction);
if (restrictions != null && restrictions.Length > 0)
{
int index = 0;
for (int i = 0; i < restrictions.Length; i++)
{
string rname = restriction[i]["RestrictionName"].ToString();
if (restrictions[i] != null)
{
// Catalog, Schema and TableType are no real restrictions
if (!rname.EndsWith("Catalog") && !rname.EndsWith("Schema") && rname != "TableType")
{
string pname = String.Format(CultureInfo.CurrentUICulture, "@p{0}", index++);
command.Parameters.Add(pname, FbDbType.VarChar, 255).Value = restrictions[i];
}
}
}
}
return command;
}
示例2: GetTables
private static List<TableSchema> GetTables(FbConnection con)
{
string[] restrict3 = {null, null, null};
string[] restrict4 = {null, null, null, null};
var aStore = new List<TableSchema>();
restrict4[0] = null;
restrict4[1] = null;
restrict4[2] = null;
restrict4[3] = "TABLE";
var dtTables = con.GetSchema("Tables", restrict4);
for (var i = 0; i < dtTables.Rows.Count; i++)
{
var tRow = dtTables.Rows[i];
var eTable = new TableSchema {Name = tRow["TABLE_NAME"].ToString()};
// Columns
restrict3[0] = null;
restrict3[1] = null;
restrict3[2] = eTable.Name;
var dtShema = con.GetSchema("Columns", restrict3);
if (dtShema.Rows.Count > 0)
eTable.Columns = new TableColumnSchema[dtShema.Rows.Count];
for (var j = 0; j < dtShema.Rows.Count; j++)
{
var cRow = dtShema.Rows[j];
var eColumn = new TableColumnSchema
{
Name = cRow["COLUMN_NAME"].ToString(),
Size = Convert.ToInt32(cRow["COLUMN_SIZE"], CultureInfo.InvariantCulture),
Type = TypeFbToDbsm(cRow["COLUMN_DATA_TYPE"].ToString()),
Nullable = Convert.ToBoolean(cRow["IS_NULLABLE"], CultureInfo.InvariantCulture)
};
eColumn.DefaultValue = HelpDbscColumnDefault(con, eColumn.Name, eTable.Name);
eColumn.DefaultValue = string.IsNullOrEmpty(eColumn.DefaultValue) ? null : eColumn.DefaultValue;
eColumn.DecimalPrecision = cRow["NUMERIC_PRECISION"] == DBNull.Value
? 0
: Convert.ToInt32(cRow["NUMERIC_PRECISION"], CultureInfo.InvariantCulture);
eColumn.DecimalScale = Convert.ToInt32(cRow["NUMERIC_SCALE"], CultureInfo.InvariantCulture);
eTable.Columns[j] = eColumn;
}
aStore.Add(eTable);
}
return aStore;
}
示例3: LoadAll
override internal void LoadAll()
{
try
{
using (FbConnection cn = new FirebirdSql.Data.FirebirdClient.FbConnection(this._dbRoot.ConnectionString))
{
cn.Open();
DataTable idxMetaData = cn.GetSchema("Indexes", new string[] { null, null, this.Table.Name });
if (!idxMetaData.Columns.Contains("CARDINALITY")) idxMetaData.Columns.Add("CARDINALITY");
if (!idxMetaData.Columns.Contains("COLUMN_NAME")) idxMetaData.Columns.Add("COLUMN_NAME");
idxMetaData.Columns["IS_UNIQUE"].ColumnName = "UNIQUE";
idxMetaData.Columns["INDEX_TYPE"].ColumnName = "TYPE";
DataTable metaData = idxMetaData.Clone();
metaData.Clear();
foreach (DataRow row in idxMetaData.Rows)
{
string indexName = (string)row["INDEX_NAME"];
DataTable metaDataColumns = cn.GetSchema("IndexColumns", new string[] { null, null, null, indexName });
metaDataColumns.DefaultView.Sort = "ORDINAL_POSITION ASC";
foreach (DataRowView vrow in metaDataColumns.DefaultView)
{
DataRow newrow = metaData.Rows.Add(row.ItemArray);
newrow["CARDINALITY"] = vrow["ORDINAL_POSITION"];
newrow["COLUMN_NAME"] = vrow["COLUMN_NAME"];
}
}
cn.Close();
PopulateArray(metaData);
}
}
catch(Exception ex)
{
string m = ex.Message;
}
}
示例4: LoadAll
internal override void LoadAll()
{
try
{
var cn = new FbConnection(_dbRoot.ConnectionString);
cn.Open();
DataTable metaData1 = cn.GetSchema("ForeignKeys", new[] {null, null, Table.Name});
DataTable metaData2 = cn.GetSchema("ForeignKeys", new[] {null, null, null, null, null, Table.Name});
cn.Close();
DataRowCollection rows = metaData2.Rows;
int count = rows.Count;
for (int i = 0; i < count; i++)
{
metaData1.ImportRow(rows[i]);
}
PopulateArrayNoHookup(metaData1);
ForeignKey key = null;
string keyName = "";
foreach (DataRow row in metaData1.Rows)
{
keyName = row["FK_NAME"] as string;
key = GetByName(keyName);
key.AddForeignColumn(null, null, (string) row["PK_TABLE_NAME"], (string) row["PK_COLUMN_NAME"], true);
key.AddForeignColumn(null, null, (string) row["FK_TABLE_NAME"], (string) row["FK_COLUMN_NAME"],
false);
}
}
catch (Exception ex)
{
string m = ex.Message;
}
}
示例5: LoadAll
internal override void LoadAll()
{
try
{
var cn = new FbConnection(_dbRoot.ConnectionString);
cn.Open();
DataTable metaData = cn.GetSchema("Procedures", new[] {Database.Name});
cn.Close();
PopulateArray(metaData);
}
catch (Exception ex)
{
string m = ex.Message;
}
}
示例6: LoadAll
override internal void LoadAll()
{
try
{
FbConnection cn = new FirebirdSql.Data.FirebirdClient.FbConnection(this._dbRoot.ConnectionString);
cn.Open();
DataTable metaData = cn.GetSchema("Procedures", new string[] {this.Database.Name});
cn.Close();
PopulateArray(metaData);
}
catch(Exception ex)
{
string m = ex.Message;
}
}
示例7: LoadForTable
internal override void LoadForTable()
{
try
{
var cn = new FbConnection(_dbRoot.ConnectionString);
cn.Open();
DataTable metaData = cn.GetSchema("Columns", new[] {null, null, Table.Name});
PopulateArray(metaData);
LoadExtraData(cn, Table.Name, "T");
cn.Close();
}
catch (Exception ex)
{
string m = ex.Message;
}
}
示例8: LoadForView
override internal void LoadForView()
{
try
{
FbConnection cn = new FirebirdSql.Data.FirebirdClient.FbConnection(this._dbRoot.ConnectionString);
cn.Open();
DataTable metaData = cn.GetSchema("Columns", new string[] {null, null, this.View.Name});
PopulateArray(metaData);
LoadExtraData(cn, this.View.Name, "V");
cn.Close();
}
catch(Exception ex)
{
string m = ex.Message;
}
}
示例9: LoadAll
override internal void LoadAll()
{
try
{
FbConnection cn = new FirebirdSql.Data.FirebirdClient.FbConnection(this._dbRoot.ConnectionString);
cn.Open();
DataTable metaData = cn.GetSchema("Views", new string[] {null, null, null});
cn.Close();
metaData.Columns["VIEW_NAME"].ColumnName = "TABLE_NAME";
PopulateArray(metaData);
}
catch(Exception ex)
{
string m = ex.Message;
}
}
示例10: LoadAll
override internal void LoadAll()
{
try
{
string type = this.dbRoot.ShowSystemData ? "SYSTEM TABLE" : "TABLE";
FbConnection cn = new FirebirdSql.Data.FirebirdClient.FbConnection(this._dbRoot.ConnectionString);
cn.Open();
DataTable metaData = cn.GetSchema("Tables", new string[] {null, null, null, type});
cn.Close();
PopulateArray(metaData);
}
catch(Exception ex)
{
string m = ex.Message;
}
}
示例11: LoadAll
internal override void LoadAll()
{
try
{
string type = dbRoot.ShowSystemData ? "SYSTEM TABLE" : "TABLE";
var cn = new FbConnection(_dbRoot.ConnectionString);
cn.Open();
DataTable metaData = cn.GetSchema("Tables", new[] {null, null, null, type});
cn.Close();
PopulateArray(metaData);
}
catch (Exception ex)
{
string m = ex.Message;
}
}
示例12: LoadAll
internal override void LoadAll()
{
try
{
var cn = new FbConnection(_dbRoot.ConnectionString);
cn.Open();
DataTable metaData = cn.GetSchema("Indexes", new[] {null, null, Table.Name});
cn.Close();
metaData.Columns["IS_UNIQUE"].ColumnName = "UNIQUE";
metaData.Columns["INDEX_TYPE"].ColumnName = "TYPE";
metaData.Columns["ORDINAL_POSITION"].ColumnName = "CARDINALITY";
PopulateArray(metaData);
}
catch (Exception ex)
{
string m = ex.Message;
}
}
示例13: LoadAll
override internal void LoadAll()
{
try
{
FbConnection cn = new FirebirdSql.Data.FirebirdClient.FbConnection(this._dbRoot.ConnectionString);
cn.Open();
DataTable metaData = cn.GetSchema("Domains", null);
cn.Close();
if(metaData.Columns.Contains("DOMAIN_DATA_TYPE"))
{
metaData.Columns["DOMAIN_DATA_TYPE"].ColumnName = "DATA_TYPE";
}
PopulateArray(metaData);
LoadExtraData(cn);
}
catch(Exception ex)
{
string m = ex.Message;
}
}
示例14: LoadForTable
override internal void LoadForTable()
{
try
{
FbConnection cn = new FirebirdSql.Data.FirebirdClient.FbConnection(this._dbRoot.ConnectionString);
cn.Open();
DataTable metaData = cn.GetSchema("Columns", new string[] { null, null, this.Table.Name });
DataColumn c;
if (!metaData.Columns.Contains("IS_AUTO_KEY")) { c = metaData.Columns.Add("IS_AUTO_KEY", typeof(Boolean)); c.DefaultValue = false; }
if (!metaData.Columns.Contains("AUTO_KEY_SEED")) { c = metaData.Columns.Add("AUTO_KEY_SEED"); c.DefaultValue = 0; }
if (!metaData.Columns.Contains("AUTO_KEY_INCREMENT")) { c = metaData.Columns.Add("AUTO_KEY_INCREMENT"); c.DefaultValue = 0; }
if (!metaData.Columns.Contains("AUTO_KEY_SEQUENCE")) { c = metaData.Columns.Add("AUTO_KEY_SEQUENCE"); c.DefaultValue = string.Empty; }
PopulateArray(metaData);
LoadExtraData(cn, this.Table.Name, "T");
cn.Close();
}
catch(Exception ex)
{
string m = ex.Message;
}
}
示例15: GetGenerators
private static List<DBGenerator> GetGenerators(FbConnection con)
{
using (var cmd = con.CreateCommand())
{
var generators = new List<DBGenerator>();
string[] restrict4 = {null, null, null, null};
restrict4[0] = null;
restrict4[1] = null;
restrict4[2] = null;
restrict4[3] = null;
var dtGenerators = con.GetSchema("Generators", restrict4);
for (var i = 0; i < dtGenerators.Rows.Count; i++)
{
var trRow = dtGenerators.Rows[i];
if (Convert.ToBoolean(trRow["IS_SYSTEM_GENERATOR"], CultureInfo.InvariantCulture))
continue;
var eGenerator = new DBGenerator
{
Name = trRow["GENERATOR_NAME"].ToString()
};
cmd.CommandText = $"SELECT gen_id(\"{eGenerator.Name}\", 0) FROM rdb$database";
eGenerator.StartValue = Convert.ToInt32(cmd.ExecuteScalar(), CultureInfo.InvariantCulture);
generators.Add(eGenerator);
}
return generators;
}
}