我需要使用nhibernate调用mysql函数,类似的sql语句:
select * from concat(',', ServiceCodes, ',') like '%,33,%';
或select * from (','||ServiceCodes||',') like '%,33,%';所以我就这样调用:
//.....or.Add(Restrictions.Like(Projections.SqlFunction("concat", NHibernateUtil.String, Projections.Property("ServiceCodes")), "%," + item + ",%"));//....Projections.SqlFunction函数第三个参数是params IProjection[] projections,但是对于逗号(,)我不知道怎么创建IProjection类似。
请各位指教
select * from concat(',', ServiceCodes, ',') like '%,33,%';
或select * from (','||ServiceCodes||',') like '%,33,%';所以我就这样调用:
//.....or.Add(Restrictions.Like(Projections.SqlFunction("concat", NHibernateUtil.String, Projections.Property("ServiceCodes")), "%," + item + ",%"));//....Projections.SqlFunction函数第三个参数是params IProjection[] projections,但是对于逗号(,)我不知道怎么创建IProjection类似。
请各位指教
或select * from (','||ServiceCodes||',') like '%,33,%';->select * from table where concat(',', ServiceCodes, ',') like '%,33,%';
或select * from table where (','||ServiceCodes||',') like '%,33,%';
另一地址:http://stackoverflow.com/questions/2680116/invoke-sql-function-using-nhibernate
Projections.Property("ServiceCodes"),
Projections.Property("ServiceCodes"),
Projections.Property("ServiceCodes"),
};