Home > Blockchain >  How to Translate Postgres query to Entity Framework Where Clause
How to Translate Postgres query to Entity Framework Where Clause

Time:05-08

How can I translate the following Postgresql query to the Entity Framework Core Where clause?

select title from some_table where title ~ '[^[:ascii:]]';

CodePudding user response:

~ is an operator for pattern matching using regular expressions. Npgsql EF Core provider automatically translates .NET's Regex.IsMatch so you can just try using it:

context.SomeTable
    .Where(t => Regex.IsMatch(t.Title, "[^[:ascii:]]"))
    ...
  • Related