invoke sql function using nhibernate?
        Posted  
        
            by net205
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by net205
        
        
        
        Published on 2010-04-21T03:29:52Z
        Indexed on 
            2010/04/21
            3:33 UTC
        
        
        Read the original article
        Hit count: 280
        
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 this code:
ICriteria cri = NHibernateSessionReader.CreateCriteria(typeof(ConfigTemplateList));
cri.Add(Restrictions.Like(Projections.SqlFunction("concat", NHibernateUtil.String, Projections.Property("ServiceCodes")), "%,33,%"));
I get sql similar :
select * from table where  (ServiceCodes) like '%,33,%';
But it is not what I want,how to do it??? thanks!
© Stack Overflow or respective owner