3
context.Company.Where(i => EF.Functions.ILike(i.Name, "xxx%")).FirstOrDefault()

I just need to use ILike in EF Core. But this function is Postgres specific. If some day the database change to Sql Server. All the code like this need to be updated.

Any ways to avoid this issue?

Mariusz Jamro
  • 30,615
  • 24
  • 120
  • 162
amingo
  • 91
  • 3
  • 10

1 Answers1

2

This seems to be database agnostic:

context.Counties.Where(x => x.Name.ToLower().Contains(keyword.ToLower())).ToList();

From: https://stackoverflow.com/a/56043524

DharmaTurtle
  • 6,858
  • 6
  • 38
  • 52