Using Registered Function for SQLite regexp operator in EF query

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for SQLite
Post Reply
klosels
Posts: 10
Joined: Wed 31 Oct 2018 16:33

Using Registered Function for SQLite regexp operator in EF query

Post by klosels » Thu 04 Jul 2019 10:04

I know that it's possible to register arbitrary functions with SQLite using the SQLiteConnection.RegisterFunction method and already used them successfully in pure SQL statements.

Is it also possible to use a registered function, specifically for the REGEXP SQLite operator, in a LINQ to Entities query?
I.e. how would I write the query on the db Set, e.g.:

Code: Select all

var doubleNamePersons = db.Set<Person>().Where(p => [b]p.LastName ...???... regexp(".*-..*")[/b]);
Thanks for any advice...

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Using Registered Function for SQLite regexp operator in EF query

Post by Shalex » Mon 08 Jul 2019 18:21


klosels
Posts: 10
Joined: Wed 31 Oct 2018 16:33

Re: Using Registered Function for SQLite regexp operator in EF query

Post by klosels » Tue 09 Jul 2019 15:26

I thoroughly read the referred topic, but I still don't see how to approach the issue.
I already know:
  • *how to register a custom function.
    *that I can then use it in a plain SQL query.
    *that registering as "regexp" will map it to the SQLite REGEXP operator (still in plain SQL)
but that doesn't yet help to use the function in LINQ to Entities because
  • *the approach in the topic linked further on applies to collating functions specific to a column, but there's no similar configuration option in SQLiteEntityProviderConfig
    *and no Regexp method exists in SqlFunctions which would map to REGEXP operator either

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Using Registered Function for SQLite regexp operator in EF query

Post by Shalex » Mon 15 Jul 2019 18:57

You are working with EF6, aren't you?

We will investigate the possibility of using REGEXP operator in EF query and notify you about the result.

klosels
Posts: 10
Joined: Wed 31 Oct 2018 16:33

Re: Using Registered Function for SQLite regexp operator in EF query

Post by klosels » Tue 13 Aug 2019 16:29

Sorry for the slow reply - yes, we're using EF 6.2

Hoping you'll find a way to support this as we'll probably need it soon and where we have no workaround.

Post Reply