Exemple #1
0
        /// <summary>
        /// Create a TableEntity and get all its columns
        /// </summary>
        /// <param name="tableSchema">schema name of the table to get</param>
        /// <param name="tableName">tableName of the table to get</param>
        /// <returns></returns>
        public TableEntity GetTableAndColumns(string tableSchema, string tableName)
        {
            using (ColumnEntityDataAccess colDa = new ColumnEntityDataAccess(this._connectionString))
            {
                TableEntity table = GetOne(string.Format("select Table_Name, Table_Schema from information_Schema.Tables WITH(NOLOCK) where table_schema = '{0}' and table_name = '{1}'", tableSchema, tableName), CreateTableEntity);
                table.AddColumns(colDa.GetAllColumnsForTable(table));
                //    // TODO: Dont add these foreign key generators here. Should be handled more central
                foreach (var column in table.Columns.Where(x => x.IsForeignKey))
                {
                    GetForeignKeyGeneratorsForColumn(column);
                }

                table.RefreshWarnings();
                return(table);
            }
        }