Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nhibernate: Retrieving column names from CreateSqlQuery

Tags:

nhibernate

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

like image 946
cbp Avatar asked Feb 02 '10 00:02

cbp


1 Answers

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

There are several existing transformers in namespace NHibernate.Transform, such as:

  • AliasToEntityMapResultTransformer Creates a map from column names to values for each row.
  • AliasToBeanResultTransformer Creates an object of the nominated type per row and sets its properties with the value from the column of the same name.
  • ToListResultTransformer Returns a list of values for each row.
like image 165
Lachlan Roche Avatar answered Nov 15 '22 07:11

Lachlan Roche