Nhibernate: getting column names from CreateSqlQuery

When using CreateSqlQuery, is it possible to get an ordered list of returned column names? Using .List returns a list of object values, not column aliases.

+4
source share
1 answer

If you apply IResultTransformer to your query via SetResultTransformer() , it will be called with two lists containing column names and values.

There are several existing NHibernate.Transform transformers in the namespace, for example:

  • AliasToEntityMapResultTransformer Creates a map from column names to values ​​for each row.
  • AliasToBeanResultTransformer Creates an object of a nominated type for each row and sets its properties with a value from a column with the same name.
  • ToListResultTransformer Returns a list of values ​​for each row.
+9
source

Source: https://habr.com/ru/post/1300000/


All Articles