I am getting problem while working with positional parameters in Nhbernate.
Criteria GroupProperty is emitting sql with both named and positional variables.
This statement:
session.CreateCriteria(typeof(MatchStageFrom))
.SetProjection(Projections.GroupProperty(
Projections.SqlFunction("substring", NHibernateUtil.String, Projections.Property("LastName"), Projections.Constant(0), Projections.Constant(1))
)
);
is producing this SQL:
SELECT substring(this_.LAST_NAME, @p0, @p1) as y0_ FROM MATCH_STAGING_FROM this_ GROUP BY substring(this_.LAST_NAME, ?, ?)
which causes SQL to error with:
Incorrect syntax near '?'.
could not execute query
[ SELECT substring(this_.LAST_NAME, @p0, @p1) as y0_ FROM MATCH_STAGING_FROM this_ GROUP BY substring(this_.LAST_NAME, ?, ?) ]
Positional parameters: #0>0 #1>1 #2>0 #3>1
[SQL: SELECT substring(this_.LAST_NAME, @p0, @p1) as y0_ FROM MATCH_STAGING_FROM this_ GROUP BY substring(this_.LAST_NAME, ?, ?)]
What can I do to fix it?