netcore sqlserver linq contains生成的sql语句不是使用like而是charIndex

在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

原文地址:https://www.cnblogs.com/zinan/p/9511163.html