当前位置: 首页>>代码示例>>C#>>正文


C# FbConnection.GetSchema方法代码示例

本文整理汇总了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;
		}
开发者ID:cafee,项目名称:NETProvider,代码行数:30,代码来源:FbSchema.cs

示例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;
		}
开发者ID:rsdn,项目名称:janus,代码行数:46,代码来源:FBSchemaLoader.cs

示例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;
			}
		}
开发者ID:nguyenhuuhuy,项目名称:mygeneration,代码行数:40,代码来源:Indexes.cs

示例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;
            }
        }
开发者ID:attila3453,项目名称:alsing,代码行数:38,代码来源:ForeignKeys.cs

示例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;
            }
        }
开发者ID:attila3453,项目名称:alsing,代码行数:16,代码来源:Procedures.cs

示例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;
			}
		}
开发者ID:nguyenhuuhuy,项目名称:mygeneration,代码行数:16,代码来源:Procedures.cs

示例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;
            }
        }
开发者ID:attila3453,项目名称:alsing,代码行数:17,代码来源:Columns.cs

示例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;
			}
		}
开发者ID:nguyenhuuhuy,项目名称:mygeneration,代码行数:18,代码来源:Columns.cs

示例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;
			}
		}
开发者ID:nguyenhuuhuy,项目名称:mygeneration,代码行数:18,代码来源:Views.cs

示例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;
			}
		}
开发者ID:nguyenhuuhuy,项目名称:mygeneration,代码行数:18,代码来源:Tables.cs

示例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;
            }
        }
开发者ID:attila3453,项目名称:alsing,代码行数:18,代码来源:Tables.cs

示例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;
            }
        }
开发者ID:attila3453,项目名称:alsing,代码行数:19,代码来源:Indexes.cs

示例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;
			}
		}
开发者ID:nguyenhuuhuy,项目名称:mygeneration,代码行数:23,代码来源:Domains.cs

示例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;
			}
		}
开发者ID:nguyenhuuhuy,项目名称:mygeneration,代码行数:23,代码来源:Columns.cs

示例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;
			}
		}
开发者ID:rsdn,项目名称:janus,代码行数:33,代码来源:FBSchemaLoader.cs


注:本文中的FirebirdSql.Data.FirebirdClient.FbConnection.GetSchema方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。