It may work better if you bind 'r' to typeof(Rez), since you use 'r' to identify it between the {}'s:
Code:
session.CreateSQLQuery(@"SELECT count(*) AS {r.id} FROM Rez {r} WHERE f_AgeInDays({r}.Create_Date, 'NOW') <= 7", "r", typeof(Rez));
I don't know if you really want to use the id property for this; you might want to check out the new scalar query feature for native sql. It's under "13.1.1. Scalar queries" in the documentation located in the doc folder of your nhibernate installation.
You'd probably end up with something like:
Code:
sess.CreateSQLQuery(@"SELECT count(*) as REZ_COUNT FROM Rez WHERE f_AgeInDays(Rez.Create_Date, 'NOW') <= 7")
.AddScalar("REZ_COUNT", NHibernateUtil.Int64);
An IList will be returned containing the scalar values (they might be wrapped in object arrays, but I'm not sure).
Hope this helps.