views:

49

answers:

1

I have the following hql query which I'd like to switch over to the criteria API

select a.Id as Id, a.Name as Name, a.ActiveStatus as ActiveStatus, 
dbo.GetActivityStartDate(a.Id) as StartDate, 
dbo.GetActivityEndDate(a.Id) as EndDate, 
coalesce(ac.Id,0) As CategoryId, 
coalesce(ac.Name,'') As CategoryName 
from Activity as a 
left outer join a.Category as ac 

Obviously the initial properties on the select line are trivial (Projections.Property); my question is..how do I map the remaining 4 properties?

I have a custom dialect that registers dbo.GetActivityStartDate and dbo.GetActivityEndDate as standard SQL functions - so that much is already taken care of.

A: 

So...it turned out that I needed to register the "ISNULL" function with my custom dialect; once I did that, it was a simple matter of using the Projections.SqlFunction to extract the data in the format I required.

DanP