protected override DbSqlParserColumnCollection GatherTableColumns(DbSqlParserTable table)
        {
            OciStatementHandle          stmtp       = new OciStatementHandle(this._connection.ServiceContextHandle);
            OciErrorHandle              errorHandle = this._connection.ErrorHandle;
            StringBuilder               builder     = new StringBuilder();
            string                      schemaName  = table.SchemaName;
            string                      tableName   = table.TableName;
            DbSqlParserColumnCollection columns     = new DbSqlParserColumnCollection();

            builder.Append("select * from ");
            if (!System.Data.Common.ADP.IsEmpty(schemaName))
            {
                builder.Append(schemaName);
                builder.Append(".");
            }
            builder.Append(tableName);
            string stmt = builder.ToString();

            if ((TracedNativeMethods.OCIStmtPrepare(stmtp, errorHandle, stmt, OCI.SYNTAX.OCI_NTV_SYNTAX, OCI.MODE.OCI_DEFAULT, this._connection) == 0) && (TracedNativeMethods.OCIStmtExecute(this._connection.ServiceContextHandle, stmtp, errorHandle, 0, OCI.MODE.OCI_DESCRIBE_ONLY) == 0))
            {
                int num3;
                stmtp.GetAttribute(OCI.ATTR.OCI_ATTR_PARAM_COUNT, out num3, errorHandle);
                for (int i = 0; i < num3; i++)
                {
                    string str;
                    OciParameterDescriptor handle = stmtp.GetDescriptor(i, errorHandle);
                    handle.GetAttribute(OCI.ATTR.OCI_ATTR_SQLCODE, out str, errorHandle, this._connection);
                    OciHandle.SafeDispose(ref handle);
                    str = this.QuotePrefixCharacter + str + this.QuoteSuffixCharacter;
                    columns.Add(null, schemaName, tableName, str, null);
                }
            }
            OciHandle.SafeDispose(ref stmtp);
            return(columns);
        }
 internal void CopySchemaInfoFrom(DbSqlParserTable table)
 {
     this._databaseName = table.DatabaseName;
     this._schemaName   = table.SchemaName;
     this._tableName    = table.TableName;
     this._isKey        = false;
     this._isUnique     = false;
 }
 internal void CopySchemaInfoFrom(DbSqlParserTable table)
 {
     this._databaseName = table.DatabaseName;
     this._schemaName = table.SchemaName;
     this._tableName = table.TableName;
     this._isKey = false;
     this._isUnique = false;
 }
        protected DbSqlParserColumn FindCompletedColumn(DbSqlParserTable table, DbSqlParserColumn searchColumn)
        {
            DbSqlParserColumnCollection columns = table.Columns;
            int count = columns.Count;

            for (int i = 0; i < count; i++)
            {
                DbSqlParserColumn column = columns[i];
                if (this.CatalogMatch(column.ColumnName, searchColumn.ColumnName))
                {
                    return(column);
                }
            }
            return(null);
        }
        internal DbSqlParserTable FindTableForColumn(DbSqlParserColumn column)
        {
            DbSqlParserTableCollection tables = this.Tables;
            int count = tables.Count;

            for (int i = 0; i < count; i++)
            {
                DbSqlParserTable table = tables[i];
                if ((System.Data.Common.ADP.IsEmpty(column.DatabaseName) && System.Data.Common.ADP.IsEmpty(column.SchemaName)) && this.CatalogMatch(column.TableName, table.CorrelationName))
                {
                    return(table);
                }
                if (((System.Data.Common.ADP.IsEmpty(column.DatabaseName) || this.CatalogMatch(column.DatabaseName, table.DatabaseName)) && (System.Data.Common.ADP.IsEmpty(column.SchemaName) || this.CatalogMatch(column.SchemaName, table.SchemaName))) && (System.Data.Common.ADP.IsEmpty(column.TableName) || this.CatalogMatch(column.TableName, table.TableName)))
                {
                    return(table);
                }
            }
            return(null);
        }
 protected abstract DbSqlParserColumnCollection GatherTableColumns(DbSqlParserTable table);
 protected abstract void GatherKeyColumns(DbSqlParserTable table);
 protected DbSqlParserColumn FindCompletedColumn(DbSqlParserTable table, DbSqlParserColumn searchColumn)
 {
     DbSqlParserColumnCollection columns = table.Columns;
     int count = columns.Count;
     for (int i = 0; i < count; i++)
     {
         DbSqlParserColumn column = columns[i];
         if (this.CatalogMatch(column.ColumnName, searchColumn.ColumnName))
         {
             return column;
         }
     }
     return null;
 }
 protected override void GatherKeyColumns(DbSqlParserTable table)
 {
     using (OracleCommand command = this._connection.CreateCommand())
     {
         command.Transaction = this._connection.Transaction;
         string schemaName = CatalogCase(table.SchemaName);
         string tableName = CatalogCase(table.TableName);
         string str = schemaName;
         string str4 = tableName;
         command.CommandText = this.GetSynonymQueryStatement(schemaName, tableName);
         using (OracleDataReader reader2 = command.ExecuteReader())
         {
             if (reader2.Read())
             {
                 str = reader2.GetString(0);
                 str4 = reader2.GetString(1);
             }
         }
         StringBuilder builder2 = new StringBuilder(ConstraintQuery1a);
         StringBuilder builder = new StringBuilder(ConstraintQuery2a);
         if (System.Data.Common.ADP.IsEmpty(str))
         {
             builder2.Append(ConstraintQuery1b_ownerDefault);
             builder.Append(ConstraintQuery2b_ownerDefault);
         }
         else
         {
             command.Parameters.Add(new OracleParameter(ConstraintOwnerParameterName, DbType.String)).Value = str;
             builder2.Append(ConstraintQuery1b_ownerIsKnown);
             builder.Append(ConstraintQuery2b_ownerIsKnown);
         }
         command.Parameters.Add(new OracleParameter(ConstraintTableParameterName, DbType.String)).Value = str4;
         builder2.Append(ConstraintQuery1c);
         builder.Append(ConstraintQuery2c);
         string[] strArray3 = new string[] { builder2.ToString(), builder.ToString() };
         foreach (string str6 in strArray3)
         {
             command.CommandText = str6;
             using (OracleDataReader reader = command.ExecuteReader())
             {
                 ArrayList list = new ArrayList();
                 bool flag2 = reader.Read();
                 bool flag = false;
                 while (flag2)
                 {
                     ConstraintColumn column;
                     list.Clear();
                     string str5 = reader.GetString(0);
                     do
                     {
                         column = new ConstraintColumn {
                             columnName = reader.GetString(1),
                             constraintType = (DbSqlParserColumn.ConstraintType) ((int) reader.GetDecimal(2)),
                             parsedColumn = null
                         };
                         list.Add(column);
                         flag2 = reader.Read();
                     }
                     while (flag2 && (str5 == reader.GetString(0)));
                     flag = true;
                     for (int i = 0; i < list.Count; i++)
                     {
                         column = (ConstraintColumn) list[i];
                         column.parsedColumn = this.FindConstraintColumn(schemaName, tableName, column.columnName);
                         if (column.parsedColumn == null)
                         {
                             flag = false;
                             break;
                         }
                     }
                     if (flag)
                     {
                         for (int j = 0; j < list.Count; j++)
                         {
                             column = (ConstraintColumn) list[j];
                             column.parsedColumn.SetConstraint(column.constraintType);
                         }
                         break;
                     }
                 }
                 if (flag)
                 {
                     return;
                 }
             }
         }
     }
 }
 protected override DbSqlParserColumnCollection GatherTableColumns(DbSqlParserTable table)
 {
     OciStatementHandle stmtp = new OciStatementHandle(this._connection.ServiceContextHandle);
     OciErrorHandle errorHandle = this._connection.ErrorHandle;
     StringBuilder builder = new StringBuilder();
     string schemaName = table.SchemaName;
     string tableName = table.TableName;
     DbSqlParserColumnCollection columns = new DbSqlParserColumnCollection();
     builder.Append("select * from ");
     if (!System.Data.Common.ADP.IsEmpty(schemaName))
     {
         builder.Append(schemaName);
         builder.Append(".");
     }
     builder.Append(tableName);
     string stmt = builder.ToString();
     if ((TracedNativeMethods.OCIStmtPrepare(stmtp, errorHandle, stmt, OCI.SYNTAX.OCI_NTV_SYNTAX, OCI.MODE.OCI_DEFAULT, this._connection) == 0) && (TracedNativeMethods.OCIStmtExecute(this._connection.ServiceContextHandle, stmtp, errorHandle, 0, OCI.MODE.OCI_DESCRIBE_ONLY) == 0))
     {
         int num3;
         stmtp.GetAttribute(OCI.ATTR.OCI_ATTR_PARAM_COUNT, out num3, errorHandle);
         for (int i = 0; i < num3; i++)
         {
             string str;
             OciParameterDescriptor handle = stmtp.GetDescriptor(i, errorHandle);
             handle.GetAttribute(OCI.ATTR.OCI_ATTR_SQLCODE, out str, errorHandle, this._connection);
             OciHandle.SafeDispose(ref handle);
             str = this.QuotePrefixCharacter + str + this.QuoteSuffixCharacter;
             columns.Add(null, schemaName, tableName, str, null);
         }
     }
     OciHandle.SafeDispose(ref stmtp);
     return columns;
 }
        internal DbSqlParserTable Add(string databaseName, string schemaName, string tableName, string correlationName)
        {
            DbSqlParserTable table = new DbSqlParserTable(databaseName, schemaName, tableName, correlationName);

            return(this.Add(table));
        }
        private void CompleteSchemaInformation()
        {
            DbSqlParserColumnCollection columns = this.Columns;
            DbSqlParserTableCollection  tables  = this.Tables;
            int count = columns.Count;
            int num10 = tables.Count;

            for (int i = 0; i < num10; i++)
            {
                DbSqlParserTable            table2   = tables[i];
                DbSqlParserColumnCollection columns4 = this.GatherTableColumns(table2);
                table2.Columns = columns4;
            }
            for (int j = 0; j < count; j++)
            {
                DbSqlParserColumn column = columns[j];
                DbSqlParserTable  table  = this.FindTableForColumn(column);
                if (!column.IsExpression)
                {
                    if ("*" == column.ColumnName)
                    {
                        columns.RemoveAt(j);
                        if (column.TableName.Length != 0)
                        {
                            DbSqlParserColumnCollection columns3 = table.Columns;
                            int num9 = columns3.Count;
                            for (int m = 0; m < num9; m++)
                            {
                                columns.Insert(j + m, columns3[m]);
                            }
                            count += num9 - 1;
                            j     += num9 - 1;
                        }
                        else
                        {
                            for (int n = 0; n < num10; n++)
                            {
                                table = tables[n];
                                DbSqlParserColumnCollection columns2 = table.Columns;
                                int num8 = columns2.Count;
                                for (int num2 = 0; num2 < num8; num2++)
                                {
                                    columns.Insert(j + num2, columns2[num2]);
                                }
                                count += num8 - 1;
                                j     += num8;
                            }
                        }
                    }
                    else
                    {
                        DbSqlParserColumn completedColumn = this.FindCompletedColumn(table, column);
                        if (completedColumn != null)
                        {
                            column.CopySchemaInfoFrom(completedColumn);
                        }
                        else
                        {
                            column.CopySchemaInfoFrom(table);
                        }
                    }
                }
            }
            for (int k = 0; k < num10; k++)
            {
                DbSqlParserTable table3 = tables[k];
                this.GatherKeyColumns(table3);
            }
        }
 protected abstract DbSqlParserColumnCollection GatherTableColumns(DbSqlParserTable table);
 protected abstract void GatherKeyColumns(DbSqlParserTable table);
 internal DbSqlParserTable Add(string databaseName, string schemaName, string tableName, string correlationName)
 {
     DbSqlParserTable table = new DbSqlParserTable(databaseName, schemaName, tableName, correlationName);
     return this.Add(table);
 }
 internal DbSqlParserTable Add(DbSqlParserTable value)
 {
     this.OnValidate(value);
     base.InnerList.Add(value);
     return(value);
 }
 internal DbSqlParserTable Add(DbSqlParserTable value)
 {
     this.OnValidate(value);
     base.InnerList.Add(value);
     return value;
 }
 protected override void GatherKeyColumns(DbSqlParserTable table)
 {
     using (OracleCommand command = this._connection.CreateCommand())
     {
         command.Transaction = this._connection.Transaction;
         string schemaName = CatalogCase(table.SchemaName);
         string tableName  = CatalogCase(table.TableName);
         string str        = schemaName;
         string str4       = tableName;
         command.CommandText = this.GetSynonymQueryStatement(schemaName, tableName);
         using (OracleDataReader reader2 = command.ExecuteReader())
         {
             if (reader2.Read())
             {
                 str  = reader2.GetString(0);
                 str4 = reader2.GetString(1);
             }
         }
         StringBuilder builder2 = new StringBuilder(ConstraintQuery1a);
         StringBuilder builder  = new StringBuilder(ConstraintQuery2a);
         if (System.Data.Common.ADP.IsEmpty(str))
         {
             builder2.Append(ConstraintQuery1b_ownerDefault);
             builder.Append(ConstraintQuery2b_ownerDefault);
         }
         else
         {
             command.Parameters.Add(new OracleParameter(ConstraintOwnerParameterName, DbType.String)).Value = str;
             builder2.Append(ConstraintQuery1b_ownerIsKnown);
             builder.Append(ConstraintQuery2b_ownerIsKnown);
         }
         command.Parameters.Add(new OracleParameter(ConstraintTableParameterName, DbType.String)).Value = str4;
         builder2.Append(ConstraintQuery1c);
         builder.Append(ConstraintQuery2c);
         string[] strArray3 = new string[] { builder2.ToString(), builder.ToString() };
         foreach (string str6 in strArray3)
         {
             command.CommandText = str6;
             using (OracleDataReader reader = command.ExecuteReader())
             {
                 ArrayList list  = new ArrayList();
                 bool      flag2 = reader.Read();
                 bool      flag  = false;
                 while (flag2)
                 {
                     ConstraintColumn column;
                     list.Clear();
                     string str5 = reader.GetString(0);
                     do
                     {
                         column = new ConstraintColumn {
                             columnName     = reader.GetString(1),
                             constraintType = (DbSqlParserColumn.ConstraintType)((int)reader.GetDecimal(2)),
                             parsedColumn   = null
                         };
                         list.Add(column);
                         flag2 = reader.Read();
                     }while (flag2 && (str5 == reader.GetString(0)));
                     flag = true;
                     for (int i = 0; i < list.Count; i++)
                     {
                         column = (ConstraintColumn)list[i];
                         column.parsedColumn = this.FindConstraintColumn(schemaName, tableName, column.columnName);
                         if (column.parsedColumn == null)
                         {
                             flag = false;
                             break;
                         }
                     }
                     if (flag)
                     {
                         for (int j = 0; j < list.Count; j++)
                         {
                             column = (ConstraintColumn)list[j];
                             column.parsedColumn.SetConstraint(column.constraintType);
                         }
                         break;
                     }
                 }
                 if (flag)
                 {
                     return;
                 }
             }
         }
     }
 }