Incorrect Syntax near “?” : Nhibernate Generated Query

前端 未结 3 702
[愿得一人]
[愿得一人] 2021-01-23 06:03

I am getting problem while working with positional parameters in Nhbernate.

Criteria GroupProperty is emitting sql with both named and positional variables.

This

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-23 06:23

    It looks like a bug in NHibernate, but if you just want those results you can get the same result by using Projections.Distinct instead of Projections.GroupProperty, ie:

    session.CreateCriteria(typeof(MatchStageFrom))
                .SetProjection(Projections.Distinct(
                    Projections.SqlFunction("substring", NHibernateUtil.String, 
                        Projections.Property("LastName"), 
                        Projections.Constant(0), 
                        Projections.Constant(1))
                    )
                );
    

    Alternatively if you're selecting more than just the first char of the name, then you could probably get it to work using a subselect

提交回复
热议问题