ÎÒÐèҪʹÓÃ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
¿ÉÁ¯£¬Ã»ÈËÀí.........
ÃìãµÄ¶¥Ò»ÏÂ...
ûÓнá¹û£¬²»ÂúÒâ½áÕË
×î½üÔÚ×ö¸öÍøÉÏÉ̳ǣ¬¹ºÎﳵģ¿é£¬Ã»ÓÐ×ö¹ý£¬Âé·³¸÷λ°ïæ˵Ï´óÖÂ˵ÏÂ˼·£¬ÄÜ·¢Ò»·ÝÔ´Âë¸üºÃ¡£Ð¡µÜÏÈл¹ý¸÷λÁË£»
QQ£º413763818£»
eamil:swebook@126.com
ÍøÉÏÒ»´ó¶Ñ£¡
www.51aspx.com
ȥϠ......
¸Õ¸Õ½Ó´¥MySQL,²»ÖªµÀ¸ÃÈçºÎÈ¥²é¿´Êý¾Ý£¬²åÈëÊý¾Ý£¬´´½¨Êý¾Ý¿â¡¢±í£¬ÓÃÄÄΪǰ±²ÄÜÖ¸½ÌÒ»¶þ£¿
MySQL 5.1²Î¿¼ÊÖ²á
ÒýÓÃ
ÐÖµÜÄã»á½áÌùÂð£¿
mysql ²Î¿¼ÊÖ²á
baidu
MySQL¹Ù·½Îĵµ http://dev.mysql.com/doc ......