Skip to content Skip to sidebar Skip to footer

Invoke Sql Function Using Nhibernate?

I want to query like this: select * from table where concat(',', ServiceCodes, ',') like '%,33,%'; select * from table where (','||ServiceCodes||',') like '%,33,%'; so, I wrote t

Solution 1:

You were in the right track, but you forgot to add what you wanted to concat.

Try this:

cri.Add(Restrictions.Like(
            Projections.SqlFunction("concat",
                                    NHibernateUtil.String,
                                    Projections.Constant(","), 
                                    Projections.Property("ServiceCodes"),
                                    Projections.Constant(",")),
        "%,33,%"));

Post a Comment for "Invoke Sql Function Using Nhibernate?"