예제 #1
0
 private void PerformPostExecute(Result rResult)
 {
     this._generatedResult = null;
     if (rResult != null)
     {
         Result r = rResult;
         while (r.GetChainedResult() != null)
         {
             r = r.GetUnlinkChainedResult();
             if (r.GetResultType() == 0x13)
             {
                 UtlException item = UtlException.SqlWarning(r);
                 if (this._sqlWarnings == null)
                 {
                     this._sqlWarnings = new List <UtlException>();
                 }
                 this._sqlWarnings.Add(item);
             }
             else if (r.GetResultType() != 2)
             {
                 if (((this._generatedResult == null) && (r.GetResultType() == 3)) && rResult.IsUpdateCount())
                 {
                     this._generatedResult = r;
                     continue;
                 }
                 if (r.GetResultType() == 3)
                 {
                     this.ResultSets.Enqueue(r);
                 }
             }
         }
         this._command.SetWarnings(this._sqlWarnings);
     }
 }
예제 #2
0
 private void CheckValidRow()
 {
     if (this._readingState != 0)
     {
         throw UtlException.GetException(Error.GetError(0xe11));
     }
 }
예제 #3
0
        public Result PrepareStatement()
        {
            this._resultOut = Result.NewPrepareStatementRequest();
            this._resultOut.SetMainString(this._sqlStatement);
            this._resultOut.SetPrepareOrExecuteProperties(this._sqlStatement, 0, 0, 0, this.queryTimeout, ResultProperties.DefaultPropsValue, this._command.FetchGeneratedResults ? 1 : 2, null, null);
            Result r = this._command.Connection.InnerConnection.SessionProxy.Execute(this._resultOut);

            if (r.IsError())
            {
                UtlException.ThrowError(r);
            }
            try
            {
                this._statementId       = r.GetStatementId();
                this._pmdDescriptor     = r.ParameterMetaData;
                this._parameterTypes    = this._pmdDescriptor.GetParameterTypes();
                this._parameterValues   = new object[this._parameterTypes.Length];
                this._streamLengths     = new long[this._parameterTypes.Length];
                this._parameterModes    = this._pmdDescriptor.ParamModes;
                this._parameterNames    = this._pmdDescriptor.ColumnLabels;
                this._isNamedParameters = this._pmdDescriptor.IsNamedParameters;
            }
            catch (Exception exception)
            {
                throw Error.GetError(0x1ca, exception.ToString());
            }
            this._resultOut = Result.NewPreparedExecuteRequest(this._parameterTypes, this._statementId);
            this._resultOut.SetStatement(r.GetStatement());
            return(r);
        }
예제 #4
0
        public Result Execute(int maxrows, int fetchsize, bool updatable)
        {
            Result rResult = null;
            Result r       = Result.NewExecuteDirectRequest();

            try
            {
                r.SetPrepareOrExecuteProperties(this._sqlStatement, maxrows, fetchsize, this.statementReturnType, this.queryTimeout, ResultProperties.DefaultPropsValue, this._command.FetchGeneratedResults ? 1 : 2, null, null);
                if (updatable)
                {
                    r.SetDataResultProperties(maxrows, fetchsize, 0x3eb, 0x3f0, 1);
                }
                rResult = this._command.Connection.InnerConnection.SessionProxy.Execute(r);
            }
            catch (CoreException exception1)
            {
                throw UtlException.GetException(exception1);
            }
            finally
            {
                this.PerformPostExecute(rResult);
                r.ClearLobResults();
            }
            if (rResult.IsError())
            {
                UtlException.ThrowError(rResult);
            }
            return(rResult);
        }
예제 #5
0
 private object GetColumnInType(object value, SqlType sourceType, SqlType targetType)
 {
     if (value == null)
     {
         return(DBNull.Value);
     }
     if (targetType.TypeCode == 0x6b)
     {
         return(new MonthSpan((int)((IntervalMonthData)value).Units));
     }
     if (targetType.TypeCode == 110)
     {
         IntervalSecondData data = (IntervalSecondData)value;
         return(new TimeSpan((data.Units * 0x989680L) + (data.Nanos / 100)));
     }
     if (sourceType.TypeCode != targetType.TypeCode)
     {
         try
         {
             value = targetType.ConvertToTypeAdo(this._command.Connection.InnerConnection.SessionProxy, value, sourceType);
         }
         catch (CoreException)
         {
             string   str        = value + "instance of " + value.GetType().Name;
             string[] textArray1 = new string[] { "from SQL type ", sourceType.GetNameString(), " to ", targetType.GetCSharpClassName(), ", value: ", str };
             string   add        = string.Concat(textArray1);
             throw UtlException.GetException(Error.GetError(0x15b9, add));
         }
     }
     return(value);
 }
예제 #6
0
        public DataTable GetIndexes(string catalog, string schema, string table, string index, string unique)
        {
            if (table == null)
            {
                throw UtlException.GetException(0x1a7);
            }
            StringBuilder builder = new StringBuilder();

            builder.Append("SELECT DISTINCT TABLE_CAT,TABLE_SCHEM,TABLE_NAME,NON_UNIQUE, INDEX_QUALIFIER,INDEX_NAME,UNIQUE_INDEX as \"UNIQUE\",PRIMARY_INDEX as\"PRIMARY_KEY\" FROM INFORMATION_SCHEMA.SYSTEM_INDEXINFO ");
            StringBuilder builder2 = null;

            if (!string.IsNullOrEmpty(unique))
            {
                bool?val = Convert.ToBoolean(unique, CultureInfo.CurrentCulture) ? ((bool?)false) : null;
                builder2 = builder.Append(" WHERE 1=1").Append(And("TABLE_CAT", "LIKE", catalog)).Append(And("TABLE_SCHEM", "LIKE", schema)).Append(And("TABLE_NAME", "LIKE", table)).Append(And("INDEX_NAME", "LIKE", index)).Append(And("NON_UNIQUE", "=", val));
            }
            else
            {
                builder2 = builder.Append(" WHERE 1=1").Append(And("TABLE_CAT", "LIKE", catalog)).Append(And("TABLE_SCHEM", "LIKE", schema)).Append(And("TABLE_NAME", "LIKE", table)).Append(And("INDEX_NAME", "LIKE", index));
            }
            DbDataReader reader = this.Execute(builder2.ToString());
            DataTable    t      = new DataTable("Indexes");

            try
            {
                PopulateDataTable(t, reader);
            }
            catch (Exception)
            {
                t.Dispose();
                throw;
            }
            return(t);
        }
예제 #7
0
 public override bool NextResult()
 {
     this.CheckClosed();
     if (this._readingState == -1)
     {
         this.FetchResult();
         this._rResult = this._resultIn;
     }
     else
     {
         if (this._resultIn == null)
         {
             return(false);
         }
         if ((this._rResult == this._resultIn) && (this._generatedResult != null))
         {
             this._rResult = this._generatedResult;
         }
         else
         {
             if ((this._resultSets == null) || (this._resultSets.Count == 0))
             {
                 return(false);
             }
             Result result = this._resultSets.Dequeue();
             this._bInit   = false;
             this._rResult = result;
         }
     }
     if (this._rResult.IsUpdateCount())
     {
         if (this._iUpdateCount == -1)
         {
             this._iUpdateCount = 0;
         }
         this._iUpdateCount += this._rResult.GetUpdateCount();
         this._readingState  = 2;
         return(this.NextResult());
     }
     if (this._rResult.IsError())
     {
         this._readingState = 2;
         UtlException.ThrowError(this._rResult);
     }
     else if (this._rResult.IsData())
     {
         this._iColumnCount = this._rResult.MetaData.GetColumnCount();
         this._readingState = 0;
     }
     else
     {
         this._readingState = 2;
     }
     return(true);
 }
예제 #8
0
 public void ReleaseSavePoint(string savePoint)
 {
     try
     {
         this.Conn.InnerConnection.SessionProxy.ReleaseSavepoint(savePoint);
     }
     catch (CoreException exception1)
     {
         UtlException.ThrowError(exception1);
     }
 }
예제 #9
0
 public void RollbackToSavePoint(string savePoint)
 {
     this.IsValid(true);
     try
     {
         this.Conn.InnerConnection.SessionProxy.RollbackToSavepoint(savePoint);
     }
     catch (CoreException exception1)
     {
         UtlException.ThrowError(exception1);
     }
 }
예제 #10
0
        public void Open()
        {
            LibCoreProperties props = this.CreateDbProperties();

            if (this.ConnectionOptions.ContextConnection)
            {
                this.SessionProxy       = UtlContext.session;
                this._isClrSpConnection = true;
            }
            else
            {
                if (this.ConnectionOptions.SlOob)
                {
                    props.SetProperty("url_sl_oob", this.ConnectionOptions.SlOob);
                }
                props.SetProperty("shutdown", this.ConnectionOptions.AutoShutdown);
                if (!string.IsNullOrEmpty(this.ConnectionOptions.CryptoType))
                {
                    props.SetProperty("crypt_type", this.ConnectionOptions.CryptoType);
                    props.SetProperty("crypt_key", this.ConnectionOptions.CryptoKey);
                    props.SetProperty("crypt_iv", this.ConnectionOptions.CryptoIv);
                }
                try
                {
                    if (!DatabaseUrl.IsInProcessDatabaseType(this.ConnectionOptions.ConnectionType))
                    {
                        throw UtlException.GetException(0x1a7, this.ConnectionOptions.ConnectionType);
                    }
                    this.SessionProxy = DatabaseManager.NewSession(this.ConnectionOptions.ConnectionType, this.ConnectionOptions.Database, this.ConnectionOptions.User, this.ConnectionOptions.Password, props, "", 0);
                    if (!this.ConnectionOptions.AutoCommit)
                    {
                        this.SessionProxy.SetAutoCommit(this.ConnectionOptions.AutoCommit);
                    }
                    if (this.ConnectionOptions.Readonly)
                    {
                        this.SessionProxy.SetReadOnlyDefault(this.ConnectionOptions.Readonly);
                    }
                    if (this.ConnectionOptions.IsolationLevel != System.Data.IsolationLevel.ReadCommitted)
                    {
                        this.SessionProxy.SetIsolationDefault((int)this.ConnectionOptions.IsolationLevel);
                    }
                }
                catch (CoreException exception1)
                {
                    throw UtlException.GetException(exception1);
                }
            }
        }
예제 #11
0
 public void CreateSavePoint(string savePoint)
 {
     if (string.IsNullOrEmpty(savePoint))
     {
         throw new ArgumentException("Required argumet missing : SavePoint");
     }
     this.IsValid(true);
     try
     {
         this.Conn.InnerConnection.SessionProxy.Savepoint(savePoint);
     }
     catch (CoreException exception1)
     {
         UtlException.ThrowError(exception1);
     }
 }
예제 #12
0
        public override string GetName(int columnIndex)
        {
            string nameString;

            try
            {
                nameString = this._rResult.MetaData.ColumnLabels[columnIndex];
                if (string.IsNullOrEmpty(nameString))
                {
                    nameString = this._rResult.MetaData.columns[columnIndex].GetNameString();
                }
            }
            catch (IndexOutOfRangeException)
            {
                throw UtlException.GetException(0x1a5, columnIndex.ToString());
            }
            return(nameString);
        }
예제 #13
0
        public override void Commit()
        {
            this.IsValid(true);
            UtlConnection conn = Interlocked.Exchange <UtlConnection>(ref this.Conn, null);

            try
            {
                conn.InnerConnection.SessionProxy.Commit(true);
            }
            catch (CoreException exception1)
            {
                UtlException.ThrowError(exception1);
            }
            finally
            {
                this.RestoreAutoCommit(conn);
            }
            this.IsCompleted = true;
        }
예제 #14
0
        public Result Execute(UtlParameterCollection parameters, int maxrows, int fetchsize, bool updatable)
        {
            Result resultIn = null;

            this.BindParameters(this._command.Parameters, this._isNamedParameters);
            this.PerformPreExecute();
            try
            {
                this._resultOut.ParameterMetaData = this._pmdDescriptor;
                if (this._command.CommandType == CommandType.StoredProcedure)
                {
                    this._resultOut.SetPreparedResultUpdateProperties(this._parameterValues);
                }
                else
                {
                    this._resultOut.SetPreparedExecuteProperties(this._parameterValues, maxrows, fetchsize, ResultProperties.DefaultPropsValue);
                }
                if (updatable)
                {
                    this._resultOut.SetDataResultProperties(maxrows, fetchsize, 0x3eb, 0x3f0, 1);
                }
                resultIn = this._command.Connection.InnerConnection.SessionProxy.Execute(this._resultOut);
                if (resultIn.GetResultType() == 0x2b)
                {
                    this.SetOutParameterValues(resultIn);
                }
                this.SetReturnParameterValue(resultIn);
            }
            catch (CoreException exception1)
            {
                throw UtlException.GetException(exception1);
            }
            finally
            {
                this.PerformPostExecute(resultIn);
                this._resultOut.ClearLobResults();
            }
            if (resultIn.IsError())
            {
                UtlException.ThrowError(resultIn);
            }
            return(resultIn);
        }
예제 #15
0
 public UtlTransaction BeginTransaction(System.Data.IsolationLevel level, bool readOnly)
 {
     lock (this)
     {
         if (this.TransactionActive)
         {
             throw new InvalidOperationException("Transaction is already active.");
         }
         try
         {
             this.Transaction = new UtlTransaction(this.Owner, level, readOnly);
         }
         catch (CoreException exception1)
         {
             throw UtlException.GetException(exception1);
         }
     }
     return(this.Transaction);
 }
예제 #16
0
        private object GetColumnInType(int columnIndex, SqlType targetType)
        {
            this.CheckClosed();
            this.CheckValidRow();
            SqlType otherType = this._rResult.MetaData.ColumnTypes[columnIndex];
            object  a         = this._nCurrent.GetCurrent()[columnIndex];

            if (a == null)
            {
                return(null);
            }
            if (targetType.TypeCode == 0x6b)
            {
                return(new MonthSpan((int)((IntervalMonthData)a).Units));
            }
            if (targetType.TypeCode == 110)
            {
                IntervalSecondData data = (IntervalSecondData)a;
                return(new TimeSpan((data.Units * 0x989680L) + (data.Nanos / 100)));
            }
            if (otherType.TypeCode != targetType.TypeCode)
            {
                try
                {
                    a = targetType.ConvertToTypeAdo(this._command.Connection.InnerConnection.SessionProxy, a, otherType);
                }
                catch (Exception)
                {
                    try
                    {
                        return(otherType.ConvertToTypeAdo(this._command.Connection.InnerConnection.SessionProxy, a, targetType));
                    }
                    catch (Exception)
                    {
                    }
                    object[] objArray1 = new object[] { "from SQL type ", otherType.GetNameString(), " to ", targetType.GetCSharpClassName(), ", value: ", a };
                    string   add       = string.Concat(objArray1);
                    UtlException.ThrowError(Error.GetError(0x15b9, add));
                }
                return(a);
            }
            return(a);
        }
예제 #17
0
        public void IssueRollback()
        {
            UtlConnection conn = Interlocked.Exchange <UtlConnection>(ref this.Conn, null);

            if (conn != null)
            {
                try
                {
                    conn.InnerConnection.SessionProxy.Rollback(true);
                }
                catch (CoreException exception1)
                {
                    UtlException.ThrowError(exception1);
                }
                finally
                {
                    this.RestoreAutoCommit(conn);
                }
            }
        }
예제 #18
0
        public Result ExecuteDirect(string sql)
        {
            Result result2;
            Result r = Result.NewExecuteDirectRequest();

            r.SetMainString(sql);
            try
            {
                result2 = this.SessionProxy.Execute(r);
                if (result2.IsError())
                {
                    throw result2.GetException();
                }
            }
            catch (CoreException exception1)
            {
                throw UtlException.GetException(exception1);
            }
            return(result2);
        }
예제 #19
0
        private void SetParameter(int i, UtlParameter param)
        {
            object o = param.Value;

            if ((o == null) || (o == DBNull.Value))
            {
                this._parameterValues[i] = null;
                return;
            }
            ISessionInterface sessionProxy = this._command.Connection.InnerConnection.SessionProxy;
            SqlType           type         = this._parameterTypes[i];
            int typeCode = type.TypeCode;

            if (typeCode <= 30)
            {
                if (typeCode > 0x15)
                {
                    switch (typeCode)
                    {
                    case 0x19:
                    case 30:
                        goto Label_028B;
                    }
                    this._parameterValues[i] = o;
                    return;
                }
                switch (typeCode)
                {
                case 0x15:
                {
                    DataTable dataTable = o as DataTable;
                    if (dataTable != null)
                    {
                        dataTable.TableName = this._parameterNames[i];
                        if (!((TableType)this._parameterTypes[i]).IsCompatible(dataTable))
                        {
                            goto Label_0379;
                        }
                        goto Label_03AF;
                    }
                    DbDataReader reader = o as DbDataReader;
                    if (reader == null)
                    {
                        goto Label_03AF;
                    }
                    dataTable = new DataTable(this._parameterNames[i]);
                    UtlMetaData.PopulateDataTable(dataTable, reader);
                    if (((TableType)this._parameterTypes[i]).IsCompatible(dataTable))
                    {
                        o = dataTable;
                        goto Label_03AF;
                    }
                    goto Label_0379;
                }
                }
            }
            else
            {
                if (typeCode <= 0x3d)
                {
                    if (typeCode == 40)
                    {
                        this._parameterValues[i] = o;
                        return;
                    }
                    if ((typeCode - 60) > 1)
                    {
                        goto Label_028B;
                    }
                    byte[] data = o as byte[];
                    if (data != null)
                    {
                        o = new BinaryData(data, !this._command.Connection.IsNetConnection);
                    }
                    else
                    {
                        try
                        {
                            if (o is string)
                            {
                                o = type.ConvertToDefaultType(sessionProxy, o);
                                goto Label_03AF;
                            }
                        }
                        catch (CoreException exception1)
                        {
                            UtlException.ThrowError(exception1);
                        }
                        UtlException.ThrowError(Error.GetError(0x15bd));
                    }
                    goto Label_03AF;
                }
                switch (typeCode)
                {
                case 0x5b:
                case 0x5c:
                case 0x5d:
                case 0x5e:
                case 0x5f:
                    try
                    {
                        if (((param.UtlType == UtlType.Null) && (o is string)) || (((param.UtlType == UtlType.VarChar) || (param.UtlType == UtlType.Char)) || (param.UtlType == UtlType.VarCharIngnoreCase)))
                        {
                            o = type.ConvertToType(sessionProxy, o, SqlType.SqlVarchar);
                        }
                        else
                        {
                            o = type.ConvertCSharpToSQL(sessionProxy, o);
                        }
                    }
                    catch (CoreException exception2)
                    {
                        UtlException.ThrowError(exception2);
                    }
                    goto Label_03AF;

                case 0x65:
                case 0x66:
                case 0x6b:
                {
                    MonthSpan span = (MonthSpan)o;
                    o = new IntervalMonthData((long)span.TotalMonths);
                    goto Label_03AF;
                }

                case 0x67:
                case 0x68:
                case 0x69:
                case 0x6a:
                case 0x6c:
                case 0x6d:
                case 110:
                case 0x6f:
                case 0x70:
                case 0x71:
                {
                    TimeSpan span2        = (TimeSpan)o;
                    long     totalSeconds = (long)span2.TotalSeconds;
                    int      nanos        = (int)((span2.TotalSeconds - totalSeconds) * 1000000000.0);
                    o = new IntervalSecondData(totalSeconds, nanos);
                    goto Label_03AF;
                }

                case 0x457:
                    try
                    {
                        if (o.GetType().IsSerializable)
                        {
                            o = new OtherData(o);
                            goto Label_03AF;
                        }
                    }
                    catch (CoreException exception3)
                    {
                        UtlException.ThrowError(exception3);
                    }
                    UtlException.ThrowError(Error.GetError(0x15bd));
                    goto Label_03AF;
                }
            }
            Label_028B :;
            try
            {
                if (((param.UtlType == UtlType.Null) && (o is string)) || (((param.UtlType == UtlType.VarChar) || (param.UtlType == UtlType.Char)) || (param.UtlType == UtlType.VarCharIngnoreCase)))
                {
                    o = type.ConvertToType(sessionProxy, o, SqlType.SqlVarchar);
                }
                else if (param.UtlType == UtlType.Null)
                {
                    o = type.ConvertToDefaultType(sessionProxy, o);
                }
                else
                {
                    SqlType type2 = this.UtlType2SqlType(param.UtlType);
                    o = type.ConvertToType(sessionProxy, o, type2);
                }
            }
            catch (CoreException exception4)
            {
                UtlException.ThrowError(exception4);
            }
            goto Label_03AF;
            Label_0379 :;
            try
            {
                if (param.UtlType == UtlType.Null)
                {
                    o = type.ConvertToDefaultType(sessionProxy, o);
                }
                else
                {
                    SqlType type3 = this.UtlType2SqlType(param.UtlType);
                    o = type.ConvertToType(sessionProxy, o, type3);
                }
            }
            catch (CoreException exception5)
            {
                UtlException.ThrowError(exception5);
            }
Label_03AF:
            this._parameterValues[i] = o;
        }
예제 #20
0
        public override DataTable GetSchemaTable()
        {
            this.CheckClosed();
            if ((this._rResult == null) || (!this._rResult.IsData() && ((this._commandBehavior & CommandBehavior.SchemaOnly) == CommandBehavior.Default)))
            {
                throw UtlException.GetException(0x1ca);
            }
            DataTable      table    = new DataTable("SchemaTable");
            ResultMetaData metaData = this._rResult.MetaData;

            table.Locale = CultureInfo.InvariantCulture;
            table.Columns.Add(SchemaTableColumn.ColumnName, typeof(string));
            table.Columns.Add(SchemaTableColumn.ColumnOrdinal, typeof(int));
            table.Columns.Add(SchemaTableColumn.ColumnSize, typeof(long));
            table.Columns.Add(SchemaTableColumn.NumericPrecision, typeof(long));
            table.Columns.Add(SchemaTableColumn.NumericScale, typeof(short));
            table.Columns.Add(SchemaTableColumn.IsUnique, typeof(bool));
            table.Columns.Add(SchemaTableColumn.IsKey, typeof(bool));
            table.Columns.Add(SchemaTableOptionalColumn.BaseServerName, typeof(string));
            table.Columns.Add(SchemaTableOptionalColumn.BaseCatalogName, typeof(string));
            table.Columns.Add(SchemaTableColumn.BaseColumnName, typeof(string));
            table.Columns.Add(SchemaTableColumn.BaseSchemaName, typeof(string));
            table.Columns.Add(SchemaTableColumn.BaseTableName, typeof(string));
            table.Columns.Add(SchemaTableColumn.DataType, typeof(Type));
            table.Columns.Add(SchemaTableColumn.AllowDBNull, typeof(bool));
            table.Columns.Add(SchemaTableColumn.ProviderType, typeof(int));
            table.Columns.Add(SchemaTableColumn.IsAliased, typeof(bool));
            table.Columns.Add(SchemaTableColumn.IsExpression, typeof(bool));
            table.Columns.Add(SchemaTableOptionalColumn.IsAutoIncrement, typeof(bool));
            table.Columns.Add(SchemaTableOptionalColumn.IsRowVersion, typeof(bool));
            table.Columns.Add(SchemaTableOptionalColumn.IsHidden, typeof(bool));
            table.Columns.Add(SchemaTableColumn.IsLong, typeof(bool));
            table.Columns.Add(SchemaTableOptionalColumn.IsReadOnly, typeof(bool));
            table.Columns.Add(SchemaTableOptionalColumn.ProviderSpecificDataType, typeof(Type));
            table.Columns.Add(SchemaTableOptionalColumn.DefaultValue, typeof(string));
            DataTable schema = null;
            DataTable table3 = null;

            if ((this._commandBehavior & CommandBehavior.KeyInfo) != CommandBehavior.Default)
            {
                string[] restrictionValues = new string[6];
                restrictionValues[1] = metaData.columns[0].GetSchemaNameString();
                restrictionValues[2] = metaData.columns[0].GetTableNameString();
                restrictionValues[5] = "true";
                schema = this._command.Connection.GetSchema("INDEXCOLUMNS", restrictionValues);
                string[] textArray2 = new string[3];
                textArray2[1] = metaData.columns[0].GetSchemaNameString();
                textArray2[2] = metaData.columns[0].GetTableNameString();
                table3        = this._command.Connection.GetSchema("COLUMNS", textArray2);
            }
            table.BeginLoadData();
            for (int i = 0; i < metaData.GetColumnCount(); i++)
            {
                DataRow row = table.NewRow();
                if ((metaData.ColumnLabels[i] == null) && string.IsNullOrEmpty(metaData.columns[i].GetNameString()))
                {
                    row[SchemaTableColumn.ColumnName] = DBNull.Value;
                }
                else
                {
                    row[SchemaTableColumn.ColumnName] = metaData.ColumnLabels[i] ?? metaData.columns[i].GetNameString();
                }
                row[SchemaTableColumn.ColumnOrdinal] = i;
                row[SchemaTableColumn.ColumnSize]    = metaData.ColumnTypes[i].GetAdoPrecision();
                row[SchemaTableColumn.ProviderType]  = metaData.ColumnTypes[i].GetAdoTypeCode();
                SqlType type = metaData.ColumnTypes[i];
                if (type.IsNumberType())
                {
                    if (type.AcceptsPrecision())
                    {
                        row[SchemaTableColumn.NumericPrecision] = ((NumberType)metaData.ColumnTypes[i]).GetNumericPrecisionInRadix();
                    }
                    else
                    {
                        row[SchemaTableColumn.NumericPrecision] = DBNull.Value;
                    }
                    if (type.AcceptsScale())
                    {
                        row[SchemaTableColumn.NumericScale] = type.GetAdoScale();
                    }
                    else
                    {
                        row[SchemaTableColumn.NumericScale] = DBNull.Value;
                    }
                }
                row[SchemaTableColumn.IsLong]                  = type.IsLobType();
                row[SchemaTableColumn.AllowDBNull]             = metaData.columns[i].GetNullability() > 0;
                row[SchemaTableOptionalColumn.IsReadOnly]      = !metaData.columns[i].IsWriteable();
                row[SchemaTableOptionalColumn.IsAutoIncrement] = metaData.columns[i].IsIdentity();
                row[SchemaTableOptionalColumn.IsHidden]        = false;
                row[SchemaTableOptionalColumn.IsRowVersion]    = false;
                row[SchemaTableColumn.IsUnique]                = false;
                row[SchemaTableColumn.IsKey]    = false;
                row[SchemaTableColumn.DataType] = this.GetFieldType(i);
                if (string.IsNullOrEmpty(metaData.columns[i].GetNameString()))
                {
                    row[SchemaTableColumn.BaseColumnName] = DBNull.Value;
                }
                else
                {
                    row[SchemaTableColumn.BaseColumnName] = metaData.columns[i].GetNameString();
                }
                row[SchemaTableColumn.IsExpression] = string.IsNullOrEmpty(metaData.columns[i].GetNameString());
                row[SchemaTableColumn.IsAliased]    = string.Compare(metaData.columns[i].GetNameString(), metaData.ColumnLabels[i], StringComparison.OrdinalIgnoreCase) > 0;
                if (string.IsNullOrEmpty(metaData.columns[i].GetTableNameString()))
                {
                    row[SchemaTableColumn.BaseTableName] = DBNull.Value;
                }
                else
                {
                    row[SchemaTableColumn.BaseTableName] = metaData.columns[i].GetTableNameString();
                }
                if (string.IsNullOrEmpty(metaData.columns[i].GetCatalogNameString()))
                {
                    row[SchemaTableOptionalColumn.BaseCatalogName] = "PUBLIC";
                }
                else
                {
                    row[SchemaTableOptionalColumn.BaseCatalogName] = metaData.columns[i].GetCatalogNameString();
                }
                if (string.IsNullOrEmpty(metaData.columns[i].GetSchemaNameString()))
                {
                    row[SchemaTableColumn.BaseSchemaName] = DBNull.Value;
                }
                else
                {
                    row[SchemaTableColumn.BaseSchemaName] = metaData.columns[i].GetSchemaNameString();
                }
                if ((this._commandBehavior & CommandBehavior.KeyInfo) != CommandBehavior.Default)
                {
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    for (int j = 0; j < schema.Rows.Count; j++)
                    {
                        string key = (string)schema.Rows[j]["INDEX_NAME"];
                        if (!dictionary.ContainsKey(key))
                        {
                            dictionary.Add(key, (string)schema.Rows[j]["COLUMN_NAME"]);
                        }
                        else
                        {
                            dictionary[key] = string.Empty;
                        }
                    }
                    foreach (string str2 in dictionary.Keys)
                    {
                        if (!string.IsNullOrEmpty(dictionary[str2]) && (string.Compare(metaData.columns[i].GetNameString(), dictionary[str2], StringComparison.OrdinalIgnoreCase) == 0))
                        {
                            row[SchemaTableColumn.IsUnique] = true;
                        }
                    }
                    for (int k = 0; k < table3.Rows.Count; k++)
                    {
                        if (string.Compare(metaData.columns[i].GetNameString(), (string)table3.Rows[k]["COLUMN_NAME"], StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            row[SchemaTableOptionalColumn.DefaultValue] = table3.Rows[k]["COLUMN_DEF"];
                            row[SchemaTableColumn.IsKey] = table3.Rows[k]["IS_PRIMARY_KEY"];
                        }
                    }
                }
                table.Rows.Add(row);
            }
            table.AcceptChanges();
            table.EndLoadData();
            return(table);
        }