我需要使用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类似。
请各位指教

解决方案 »

  1.   

    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,%';
      

  2.   

    等待答案。
    另一地址:http://stackoverflow.com/questions/2680116/invoke-sql-function-using-nhibernate
      

  3.   

    new IProjection[]{
      Projections.Property("ServiceCodes"), 
    Projections.Property("ServiceCodes"), 
    Projections.Property("ServiceCodes"), 
    };