You're right. ITableMetadata does not expand the column names in the table. It seems that classes were designed for use with mapping files that explicitly specify column names. However, if you take a quick look at Reflector, you will find that all column names are actually stored in a private variable in the AbstractTableMetadata class (from which all ITableMetadata implementations are derived.
Here is the code to extract all column names from all tables in the database:
var dialect = sess.GetSessionImplementation().Factory.Dialect; var dbSchema = dialect.GetDataBaseSchema(sess.Connection as DbConnection); foreach (DataRow row in (sess.Connection as DbConnection).GetSchema("Tables").Rows) { ITableMetadata md = dbSchema.GetTableMetadata(row, false); var hiddenColumnsProperty = typeof(AbstractTableMetadata).GetField("columns", BindingFlags.NonPublic | BindingFlags.Instance); var columns = hiddenColumnsProperty.GetValue(md) as Dictionary<string, IColumnMetadata>; foreach (var colName in columns.Keys) { Console.WriteLine(md.Name+"."+colName); } }
source share