I tried to ask this question yesterday, but I don't think my wording was very clear.
Therefore, I've tried to reword the question below.
We have an existing system which we are rewriting in MVC4, and we are using NHibernate 3.2 in our new system.
In the old system, we build up a SQL statement similar to this:
SELECT myField as series,
pstatus,
Year(acc_date) AS year,
Month(acc_date) AS month,
COUNT(CAST(reportable AS INT)) AS totalreportable,
SUM(CAST(reportable AS INT)) AS riddorreportable,
SUM(CAST(lt_acc AS INT)) AS losttime,
SUM(CAST(acc_losttime AS INT)) AS totaldayslost,
SUM(CAST(nearmiss AS INT)) AS nearmiss
FROM incident
WHERE 1=1
In the above, we will be replacing "WHERE 1=1" with nHibernate criteria (which we already have in the system to filter data).
myField in the above SQL statement is a field which is selectable by the user e.g. he could choose Department, City etc.
What I need, therefore, is information on how to use nHibernate to achieve the same result as the above SQL statement.