c# - NHibernate unmapped table - object is a multicolumn type - ToListResultTransformer -
i have nhibernate executing raw sql query built database. in software use able choose table , couple of columns defined order. in software use information build sql query selects defined columns table , concatenates columns 1 column. here quick example.
the user defines wants select columns firstname
und surname
table user
. build select statement:
select (firstname || surname) resultdata user
and try use select statement:
var list = session.createsqlquery(sqlquery) .setresulttransformer(new nhibernate.transform.tolistresulttransformer()) .list();
but problem genericadoexception
message
object multicolumn type
i didn't found on internet problem. thread accomplishs same task without error: nhibernate sql query mapping on single column result
yeah, found problem. no problem code rather database.
there columns have null
values, , nhibernate didn't liked that.
firstname | surname ------------------- sam | smith | archer michael | brown
i solved problem adjustment of sql satement. i'm using coalesce
function.
the new sql statement:
select (coalesce(firstname, '') || coalesce(surname, '')) resultdata user
Comments
Post a Comment