I have a UWP
project that works with Sqlite
database. I added sqlite-net-pcl
to my references.
I want to use REGEXP
in select
query but it gives me the no such function: REGEXP
.
I searched the error but the results are about SQLiteFunction
that is not defined here.
what should I do?
At the end I installed sqlite-net-pcl
from nuget
not the one in the Universal windows extensions
in ReferenceManger.
sqlite-net-pcl
package in nuget has sqlite3_create_function
method.
SQLiteConnection con = new SQLiteConnection(@"myDB.db");
SQLitePCL.raw.sqlite3_create_function(con.Handle, "REGEXP", 2, null, MatchRegex);
private void MatchRegex(sqlite3_context ctx, object user_data, sqlite3_value[] args)
{
bool isMatched = System.Text.RegularExpressions.Regex.IsMatch(SQLitePCL.raw.sqlite3_value_text(args[1]), SQLitePCL.raw.sqlite3_value_text(args[0]),RegexOptions.IgnoreCase);
if (isMatched)
SQLitePCL.raw.sqlite3_result_int(ctx, 1);
else
SQLitePCL.raw.sqlite3_result_int(ctx, 0);
}
this works fine :)