AzurePoolCrossDbGenerator/DbAccess.cs
/// <summary>
/// Returns a list of columns not supported by ElasticQuery for generating ALTER TABLE statements
/// </summary>
/// <param name="connectionString"></param>
/// <param name="tableName"></param>
/// <returns></returns>
Returns a list of columns not supported by ElasticQuery for generating ALTER TABLE statements
Returns a list of columns not supported by ElasticQuery for generating ALTER TABLE statements
public static List<ColumnDefinition> GetIncompatibleTableColumns(string connectionString, string tableName)
        {
            string queryString = @"select COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE 
                from INFORMATION_SCHEMA.COLUMNS
                where table_name = @table_name";
            var outColumns = new List<ColumnDefinition>(); 
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand(queryString, connection);
                command.Parameters.AddWithValue("@table_name", tableName);
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                try
                {
                    while (reader.Read())
                    {
                        var colDef = new ColumnDefinition
                        {
                            colName = reader["COLUMN_NAME"].ToString(),
                            colType = reader["DATA_TYPE"].ToString(),
                            colLen = reader["CHARACTER_MAXIMUM_LENGTH"].ToString(),
                            colPrecision = reader["NUMERIC_PRECISION"].ToString(),
                            colScale = reader["NUMERIC_SCALE"].ToString()
                        };
                        if (string.Equals(colDef.colType, "text", StringComparison.OrdinalIgnoreCase) ||
                            string.Equals(colDef.colType, "image", StringComparison.OrdinalIgnoreCase)
                            )
                        {
                            outColumns.Add(colDef);
                        }
                    }
                }
                finally
                {
                    reader.Close();
                }
            }
            return outColumns;
        }
public static List < ColumnDefinition > GetIncompatibleTableColumns ( string connectionString , string tableName ) { string queryString = @"select COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE 
                from INFORMATION_SCHEMA.COLUMNS
                where table_name = @table_name" ; var outColumns = new List < ColumnDefinition > ( ) ; using ( SqlConnection connection = new SqlConnection ( connectionString ) ) { SqlCommand command = new SqlCommand ( queryString , connection ) ; command . Parameters . AddWithValue ( " " , tableName ) ; connection . Open ( ) ; SqlDataReader reader = command . ExecuteReader ( ) ; try { while ( reader . Read ( ) ) { var colDef = new ColumnDefinition { colName = reader [ " " ] . ToString ( ) , colType = reader [ " " ] . ToString ( ) , colLen = reader [ " " ] . ToString ( ) , colPrecision = reader [ " " ] . ToString ( ) , colScale = reader [ " " ] . ToString ( ) } ; if ( string . Equals ( colDef . colType , " " , StringComparison . OrdinalIgnoreCase ) || string . Equals ( colDef . colType , " " , StringComparison . OrdinalIgnoreCase ) ) { outColumns . Add ( colDef ) ; } } } finally { reader . Close ( ) ; } } return outColumns ; }
Returns a list of columns not supported by ElasticQuery for generating ALTER TABLE statements
Returns a list of columns not supported by ElasticQuery for generating ALTER TABLE statements
// select column definitions from INFORMATION_SCHEMA.COLUMNS // output container // read the column definition // add columns of a matching type // remove trailing , and new line
None
connectionString
string
None
tableName
string
None