[英]How to do a LIKE in Entity Framework CORE (not full .net)
完整的 .net 框架中有實體框架 LIKE 的 Q+A:
如何在 Linq 中執行 SQL Like %?
像實體框架中的運算符?
例如:
from c in dc.Organization
where SqlMethods.Like(c.Boss, "%Jeremy%")
這在 EF Core 中不起作用:
當前上下文中不存在名稱 SqlMethods。
那么如何使用 Entity Framework CORE 執行 LIKE 操作呢?
LIKE 函數已移至 Core 中的EF.Functions
下:
from c in dc.Organization
where EF.Functions.Like(c.Boss, "%Jeremy%")
您可以使用Contains
而不是Like
函數
from c in dc.Organization
where c.Boss.Contains("Jeremy")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.