实体框架核心Postgre ILike函数

时间:2019-03-01 07:44:44

标签: c# asp.net postgresql asp.net-core entity

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

我只需要在EF Core中使用ILike。但是此功能是Postgres特有的。 如果有一天,数据库更改为Sql Server。像这样的所有代码都需要更新。

有什么办法可以避免这个问题?

1 个答案:

答案 0 :(得分:0)

这似乎与数据库无关:

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

来自:https://stackoverflow.com/a/56043524