I need the following condition (in SQL) to fill a specific field in my resultset:
CASE
WHEN M.ID_ENTIDAD = m.ID_ENTIDAD_VENTA then EC.CLAVE_ENTIDAD
END AS Contraparte }
If I use
var contraparte = Projections.Conditional(
Restrictions.EqProperty("EntidadOwner", "EntidadVenta"),
Projections.Property("enc.CvePrincipalMiembro"),
null);
That return an error.
Also if I use:
*var contraparte = Projections.Conditional(
Restrictions.EqProperty("EntidadOwner", "EntidadVenta"),
Projections.Property("enc.CvePrincipalMiembro"),
Projection.Constant(a constant value);*
Apparently it is not possible to use this Conditional without ELSE part. that is nhibernate can not generate CASE without ELSE part.
It is possible to do this?? Please help me!!!
Thanks
Ok. I found self the response.
I took two actions:
One, add the following dummy field in the map class used in your query:
Second: I modified the conditional projection with the following code:
That was all! I hope that this help another people with the same problem.