當前位置: 首頁>>代碼示例>>C#>>正文


C# OracleConnection.GetSchema方法代碼示例

本文整理匯總了C#中Oracle.DataAccess.Client.OracleConnection.GetSchema方法的典型用法代碼示例。如果您正苦於以下問題:C# OracleConnection.GetSchema方法的具體用法?C# OracleConnection.GetSchema怎麽用?C# OracleConnection.GetSchema使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Oracle.DataAccess.Client.OracleConnection的用法示例。


在下文中一共展示了OracleConnection.GetSchema方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetSchema

        /// <summary>
        /// 返回指定名稱的架構信息 
        /// </summary>
        /// <param name="collectionName">集合名稱</param>
        /// <returns>DataTable</returns>
        public static DataTable GetSchema(string collectionName)
        {
            using (OracleConnection connection = new OracleConnection(connectionString))
            {

                DataTable dt = new DataTable();

                try
                {

                    dt.Clear();

                    connection.Open();

                    dt = connection.GetSchema(collectionName);

                }

                catch
                {

                    dt = null;

                }

                return dt;

            }
        }
開發者ID:GitOffice,項目名稱:DataPie,代碼行數:34,代碼來源:DbHelperOra.cs

示例2: Connection

        public DbConnection Connection(DatabaseType dbT, string cs)
        {
            DbConnection c = null;

            switch (dbT)
            {
                case DatabaseType.SQLite: c = new SQLiteConnection(cs); break;
                case DatabaseType.Access: c = new OleDbConnection(cs); break;
                case DatabaseType.Oracle: c = new OracleConnection(cs); break;
                default: break;
            }

            try
            {
                c.Open();
                c.GetSchema("Tables");
            }
            catch
            {
                return null;
            }
            return c;
        }
開發者ID:jalil1408,項目名稱:BiomPSP,代碼行數:23,代碼來源:UtlDb.cs

示例3: GetSchema_OracleDA

        private DataTable GetSchema_OracleDA()
        {
            OracleConnection conn;
            string connetionString = GetConnectionString_OracleDA();
            conn = new OracleConnection(connetionString);

            try
            {
                conn.Open();
                DataTable schemaTable = conn.GetSchema();
                return schemaTable;
            }
            catch (OracleException ex)
            {
                MessageBox.Show("Exception in GetSchema_OracleDA - " + ex.Message);
            }
            finally
            {
                conn.Close();
            }
            return null;
        }
開發者ID:refinedculture,項目名稱:HowToConnectToOracleDatabases,代碼行數:22,代碼來源:Form1.cs

示例4: GetSchema

 /// <summary>
 /// 獲取架構信息
 /// </summary>
 /// <param name="connectionString"></param>
 /// <param name="collectionName"></param>
 /// <param name="restrictionValues"></param>
 /// <returns></returns>
 public static DataTable GetSchema(string connectionString, string collectionName, string[] restrictionValues)
 {
     OracleConnection connection = new OracleConnection(connectionString);
     DataTable schema = new DataTable();
     try
     {
         connection.Open();
         if (!string.IsNullOrEmpty(collectionName))
         {
             if (restrictionValues != null && restrictionValues != null && restrictionValues.Length > 0)
             {
                 schema = connection.GetSchema(collectionName, restrictionValues);
             }
             else
             {
                 schema = connection.GetSchema(collectionName);
             }
         }
         else
         {
             schema = connection.GetSchema();
         }
     }
     catch
     {
         schema = null;
     }
     finally
     {
         connection.Close();
     }
     return schema;
 }
開發者ID:hhahh2011,項目名稱:CH.Gps,代碼行數:40,代碼來源:DbOracleHelper.cs

示例5: OracleGetShcema

        private void OracleGetShcema()
        {
            try
            {
                using (var conn = new OracleConnection(txtOrclConn.Text))
                {
                    conn.Open();
                    string[] restriction = new string[] { txtOrclOwner.Text };

                    DataTable schema;
                    if (txtOrclSchemaName.Text.ToLower() == "datatypes")
                    {
                        schema = conn.GetSchema(txtOrclSchemaName.Text);
                    }
                    else if (txtOrclSchemaName.Text.Length > 0)
                    {
                        schema = conn.GetSchema(txtOrclSchemaName.Text, restriction);
                    }
                    else
                        schema = conn.GetSchema();

                    grdGrid.DataSource = schema;
                    grdColumns.DataSource = GetColumns(schema.Columns);
                }
            }
            catch
            {
                throw;
            }
        }
開發者ID:GitOffice,項目名稱:SalarDbCodeGenerator,代碼行數:30,代碼來源:frmTest.cs

示例6: Main

        public static void Main(string[] args)
        {
            var nameSpace = args[0];

            var match = new Regex("^(?<user>[a-zA-Z0-9]+)/(?<password>[a-zA-Z0-9]+)@(?<tnsName>[a-zA-Z0-9]+)").Match(args[1]);
            var user = match.Groups["user"].Value;
            var password = match.Groups["password"].Value;
            var tnsName = match.Groups["tnsName"].Value;

            var connectionString = String.Format(
                "User Id={0};Password={1};Data Source={2}",
                user,
                password,
                tnsName);

            using (var conn = new OracleConnection(connectionString))
            {
                try
                {
                    conn.Open();
                }
                catch (OracleException ex)
                {
                    Console.WriteLine(ex.Message);
                    return;
                }

                var typeDictionary = conn.GetSchema("DataTypes").AsDynamic()
                    .ToDictionary(x =>
                        x.TypeName,
                        x => (Type)Type.GetType(x.DataType));

                Func<string, bool, decimal, decimal, string> getTypeName = (dataType, isNullable, precision, scale) =>
                {
                    var type = typeDictionary[dataType];
                    var typeName = type.Name;
                    if (precision > 0 && scale == 0)
                    {
                        // NUMBER型が無條件にDecimalになるので、小數桁數が0なら整數型として扱う
                        if (precision < 10)
                        {
                            typeName = "Int32";
                        }
                        else
                        {
                            typeName = "Int64";
                        }
                    }
                    return (isNullable && type.IsValueType)
                        ? typeName + "?" // 値型かつnull許可の時
                        : typeName;
                };

                var columnGroups = conn.GetSchema("Columns").AsDynamic()
                    .Where(x => x.OWNER == user)
                    .GroupBy(x => x.TABLE_NAME) // 全てのカラムが平らに列挙されてくるのでテーブル名でグルーピング
                    .Select(g => new
                    {
                        ClassName = g.Key, // クラス名はテーブル名(= グルーピングのキー)
                        Properties = g
                            .OrderBy(x => x.ID) // どんな順序で來るか不明なので、カラム定義順にきちんと並び替え
                            .Select(x => new
                            {
                                Name = x.COLUMN_NAME,
                                Type = getTypeName(
                                    x.DATATYPE,
                                    x.NULLABLE == "Y",
                                    x.PRECISION ?? 0m,
                                    x.SCALE ?? 0m)
                            })
                            .ToArray()
                    });

                foreach (var item in columnGroups)
                {
                    var tt = new TableGeneratorTemplate(nameSpace, item.ClassName, item.Properties);
                    var text = tt.TransformText();
                    File.WriteAllText(item.ClassName + ".cs", text, Encoding.UTF8);
                }
            }
        }
開發者ID:masaru-b-cl,項目名稱:EntityClassGeneratorForOracle,代碼行數:81,代碼來源:Program.cs


注:本文中的Oracle.DataAccess.Client.OracleConnection.GetSchema方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。