4
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?

2
  • why cant you use normal linq syntax ? Commented Mar 1, 2019 at 9:14
  • i need use ILike Commented Mar 4, 2019 at 9:01

1 Answer 1

3

This seems to be database agnostic:

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

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.