Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 609
Jeremy Thompson Avatar asked Nov 14 '17 04:11

Jeremy Thompson


People also ask

Is EF core faster than EF6?

EF Core 6.0 itself is 31% faster executing queries. Heap allocations have been reduced by 43%.

Can I use Entity Framework 6 not core in .NET core?

To use Entity Framework 6, your project has to compile against . NET Framework, as Entity Framework 6 doesn't support . NET Core. If you need cross-platform features you will need to upgrade to Entity Framework Core.


1 Answers

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

from c in dc.Organization
where EF.Functions.Like(c.Boss, "%Jeremy%")
like image 108
Jeremy Thompson Avatar answered Oct 06 '22 11:10

Jeremy Thompson