nhibernate调用mysql函数问题

net205 2010-04-21 11:04:00
我需要使用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类似。


请各位指教。。。

...全文
241 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
net205 2010-05-11
  • 打赏
  • 举报
回复
没有结果,不满意结账
liq1979 2010-04-23
  • 打赏
  • 举报
回复
new IProjection[]{
Projections.Property("ServiceCodes"),
Projections.Property("ServiceCodes"),
Projections.Property("ServiceCodes"),
};
sxiaohui8709253 2010-04-23
  • 打赏
  • 举报
回复
帮你顶
net205 2010-04-23
  • 打赏
  • 举报
回复
渺茫的顶一下...
net205 2010-04-21
  • 打赏
  • 举报
回复
等待答案。
另一地址:http://stackoverflow.com/questions/2680116/invoke-sql-function-using-nhibernate
doo1314 2010-04-21
  • 打赏
  • 举报
回复
帮你顶起来
net205 2010-04-21
  • 打赏
  • 举报
回复
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,%';
net205 2010-04-21
  • 打赏
  • 举报
回复
可怜,没人理.........

110,499

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧