我需要使用nhibernate调用mysql函数,类似的sql语句:
select * from concat(',', ServiceCodes, ',') like '%,33,%';
或select * from (','||ServiceCodes||',') like '%,33,%';
所以我就这样调用:
//.....
C# code:
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,%';
->
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
可怜,没人理.........
渺茫的顶一下...
没有结果,不满意结账
可能因为工作的原因 接触数据库这块比较少,之前都是做程序这块,数据库这块都有专门的人来做 分工都很明细 所以对数据库这一块完全不了解。前段时间 去面试了几家公司 几乎都是在数据库这块挂掉的 连个简单的SQ ......