在ef中使用linq调用了contains,结果怎么都查不到值,打开sqlserver profiler 发现生成的sql语句不是使用like。。。而是CharIndex

参考文档:https://stackoverflow.com/questions/47277630/how-to-do-a-like-in-entity-framework-core-not-full-net

解决办法:EF.Functions.Like(c.Boss, "%Jeremy%")

 

其实使用charIndex也可以实现like的模糊检索效果,而且效率要比like高,具体见参数:http://www.cnblogs.com/a2008a/archive/2008/11/14/1333299.html

posted on 2018-08-21 14:31  芝麻的西瓜  阅读(356)  评论(0编辑  收藏  举报