Mar*_*yam 3 c# sqlite sqlite-net uwp
我有一个UWP与数据库一起使用的项目Sqlite。我添加sqlite-net-pcl到我的参考文献中。REGEXP我想在查询中使用,select但它给了我no such function: REGEXP. 我搜索了错误,但结果是关于SQLiteFunction此处未定义的。我应该怎么办?
最后我安装的sqlite-net-pcl不是ReferenceMangernuget中的那个Universal windows extensions。
sqlite-net-pclnuget中的包有sqlite3_create_function方法。
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);
    }
Run Code Online (Sandbox Code Playgroud)
这很好用:)
|   归档时间:  |  
           
  |  
        
|   查看次数:  |  
           737 次  |  
        
|   最近记录:  |