是否可以使用 npgsql 在 EF CORE 3.1 中使用 UNACCENT 扩展对 postgresql 进行选择?

net*_*fan 6 postgresql npgsql ef-core-3.1

我已经在 Npgsql and Entity Framework Query PostgreSQL with Npgsql and Entity Framework using unaccent中读到过有关此内容,但实体框架核心。

\n\n

是否可以使用 EF CORE 3.1 使用非重音扩展对 postgresql 进行选择?

\n\n

如何翻译,例如

\n\n
\n

select * from users where unaccent(name) = unaccent(\'Jo\xc3\xa3o\')

\n
\n\n

使用 EF core 和 npgsql 到 .net core 3.1

\n\n

谢谢

\n

ras*_*ino 1

解决方案在这里: Query PostgreSQL with Npgsql and Entity Framework using unaccent

首先注册扩展:

protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.HasPostgresExtension("unaccent");
            ...
        }
Run Code Online (Sandbox Code Playgroud)

然后你可以使用扩展EF.Functions.Unaccent

.Where(x => people.ILike(EF.Functions.Unaccent(x.Name)....
Run Code Online (Sandbox Code Playgroud)