Hello
I would like how to have a specific output in nhibernate
var hql = @"select t1.info1, t2.info2
from table1 t1
left outer join t1.table2 t2";
var variable = session.CreateQuery(hql).List();
That query return an object array which contains another array.
ie : in the first line, info1 can be retrieved by variable[0][0]
and in the same line, info2 can be retrieved by variable[0][1]
I know that I can create a new Class like
class SpecificQuery
{
public int info1;
public int? info2
}
and then call :
session.CreateQuery(hql)
.SetResultTransformer(new AliasToBeanResultTransformer(typeof(SpecificQuery))).List();
But I don’t want to create a specific class each time I want to have a special return.
Does someone know a solution to that problem ?
For example, a IList< Dictionnary< string, object>>[]
In this case, the first line of info1 can be retrieve by variable0 (in case of variable[0][0]
Thanks
You can use the AliasToEntityMapResultTranformer
This will return a list of IDictionary objects.