How to do a LIKE in Entity Framework CORE (not full .net)

.net-core c# entity-framework-core sql-server

Question

There are Q+A's for Entity Framework LIKE's in the Full .net framework:

How to do SQL Like % in Linq?
Like Operator in Entity Framework?

eg:

from c in dc.Organization
where SqlMethods.Like(c.Boss, "%Jeremy%")

This doesn't work in EF Core:

The name SqlMethods does not exist in the current context.


So how do you do a LIKE using Entity Framework CORE?

1
7
1/25/2020 12:36:30 AM

Accepted Answer

The LIKE function has moved under EF.Functions in Core:

from c in dc.Organization
where EF.Functions.Like(c.Boss, "%Jeremy%")
17
11/14/2017 4:22:29 AM

Popular Answer

Instead of Like function you can use Contains

from c in dc.Organization
where c.Boss.Contains("Jeremy") 


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow