The issue is here
http://jira.nhibernate.org/browse/NH-1393
Basically, the problem is we cannot do following
[Test]
public void CanAvgProjectionOnSqlFunction()
{
using (ISession s = OpenSession())
{
ISQLFunction arithmaticAddition = new VarArgsSQLFunction("(", "+", ")");
ICriteria c = s.CreateCriteria(typeof(Person))
.SetProjection(
Projections.Avg(Projections.SqlFunction(arithmaticAddition,
NHibernateUtil.GuessType(typeof(double)),
Projections.Property("IQ"),
Projections.Property("ShoeSize"))));
IList list = c.List();
Assert.AreEqual( 334/5,list[0]);
}
}
What I want to ask is, should I go for SqlFunction projections, or any projection. Projection is not error-safe, I mean user may try to aggregate on Subquery projection, which is illegal in MSSQL(and probably the others.
So my question is, Should I go for Projection or restrict it to SqlFunctionProjection.