Domanda

I use the fallowing HQL-Query with NHibernate:

from Contact a where 
a.Id in (select x.Person.Id from PersonCompany x 
            inner join x.Company y 
            inner join y.Addresses z 
         where isnull(z.Street,'')+isnull(z.PostalCode,'')  Like :val) 

In this query, NHibernate tries to convert :val (which is a string) to a double. z.Street and z.PostalCode are string-fields which can bee null. It looks like NHibernate has a problem with the first isnull() in the where-clause. when I use z.Street+isnull(z.PostalCode,'') it is working. I have also tried cast(isnull(z.Street,'')+isnull(z.PostalCode,'') as string) but this is also not working, because NHibernate has a Problem with the cast-function (it generates more then two parameters). Can someone help me, how I can solve this with NHibernate? - Perhaps there is another way to write the where-condition?

I use NHibernate 3.2

È stato utile?

Soluzione

Try concat(coalesce(z.Street,''), coalesce(z.PostalCode,''))

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top