Projections.SqlFunction("coalesce", NHibernateUtil.String,
Projections.Property("Column1"), Projections.Property("Column2"));

The parameters to the coalesce (or any other) function should be passed
separately (actually, as a params array), not merged into a ProjectionList.

    Diego


On Thu, Sep 2, 2010 at 19:31, NotAnXpert <[email protected]> wrote:

> My goal is to invoke coalesce operator in select statement "order by"
> clause using NHibernate Criteria API.
>
> Does the API support coalesce function? Reason being I tried the
> following snippet but it did not yield the desired results. In fact I
> could not see the coalesce operator in the resulting sql using
> NHibernate profiler.
>
> var projectionList = Projections.ProjectionList();
> projectionList.Add(Projections.Property("Column1"));
> projectionList.Add(Projections.Property("Column2"));
>
> var result = Projections.SqlFunction("coalesce",
> NHibernateUtil.String, projectionList);
>
> I am performing a complex join involving over 7 tables and I am
> interested in sorting the result set by 2 columns (one of which could
> be null; hence the coalesce)
>
> I'd seen a lot of examples on which involves invoking SQL functions
> such as Year, Month etc but not with coalesce.
>
> Any pointers on how to go about with it?
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to