Like Operator in Entity Framework?
Like Operator in Entity Framework?
回答1
This is an old post now, but for anyone looking for the answer, this link should help. Go to this answer if you are already using EF 6.2.x. To this answer if you're using EF Core 2.x
Short version:
SqlFunctions.PatIndex method - returns the starting position of the first occurrence of a pattern in a specified expression, or zeros if the pattern is not found, on all valid text and character data types
Namespace: System.Data.Objects.SqlClient Assembly: System.Data.Entity (in System.Data.Entity.dll)
A bit of an explanation also appears in this forum thread.
回答2
There is LIKE
operator is added in Entity Framework Core 2.0
:
var query = from e in _context.Employees
where EF.Functions.Like(e.Title, "%developer%")
select e;
Comparing to ... where e.Title.Contains("developer") ...
it is really translated to SQL
LIKE
rather than CHARINDEX
we see for Contains
method.
回答3
Update: In EF 6.2 there is a like operator
Where(obj => DbFunctions.Like(obj.Column , "%expression%"))
作者:Chuck Lu GitHub |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2021-09-15 专科是文科,是否可以报考理科的本科
2021-09-15 一网通办 下载发票
2017-09-15 asp.net的临时文件夹
2017-09-15 Cms WebSite 编译非常慢
2015-09-15 access to modified closure 闭包的问题
2015-09-15 错误信息:A TCP error (10013: 以一种访问权限不允许的方式做了一个访问套接字的尝试。) occurred while listening on IP Endpoint=192.168.1.18:8002.
2015-09-15 如何kill掉TaobaoProtect.exe