/// <summary> /// Returns string with CREATE TABLE sql for the table which owns this index. /// </summary> /// <param name="connection">Connection to use to execute query.</param> /// <param name="row">DataRow with information about index.</param> /// <returns>Returns string with CREATE TABLE sql for this table.</returns> private static string GetCreateTableQuery(DataConnectionWrapper connection, DataRow row) { // Extract schema and table name string schemaName = DataInterpreter.GetString(row, Attributes.Schema); string tableName = DataInterpreter.GetString(row, Attributes.Table); if (String.IsNullOrEmpty(schemaName) || String.IsNullOrEmpty(tableName)) { Debug.Fail("Unable to get table or schema name"); return(String.Empty); } return(TableDescriptor.GetCreateTableQuery(connection, schemaName, tableName)); }
/// <summary> /// Reads table with Database Objects which satisfy given restriction. Uses table enumeration for legacy /// version. /// </summary> /// <param name="connection">The DataConnectionWrapper to be used for enumeration.</param> /// <param name="restrictions">The restrictions to be putted on the retrieved objects set.</param> /// <param name="sort">Sort expresion to append after ORDER BY clause.</param> /// <returns>Returns table with Database Objects which satisfy given restriction.</returns> protected override DataTable ReadTable(DataConnectionWrapper connection, object[] restrictions, string sort) { if (connection == null) { throw new ArgumentNullException("connection"); } // Extract server version Version serverVersion = connection.ServerVersion; // For latest version just return base result if (serverVersion == null || serverVersion.Major >= 5) { return(base.ReadTable(connection, restrictions, sort)); } ; // For legacy version enumerate tables DataTable result = TableDescriptor.Enumerate(connection, restrictions); // If result is empty, return it if (result == null) { return(null); } // Add is updatable column result.Columns.Add(Attributes.IsUpdatable, typeof(string)); // Set is updatable to true for each row foreach (DataRow table in result.Rows) { DataInterpreter.SetValueIfChanged(table, Attributes.IsUpdatable, DataInterpreter.True); } // Finaly, return result return(result); }