Create/Use User-defined functions in System.Data.SQLite?

后端 未结 1 1659
感情败类
感情败类 2020-11-30 01:36

User-Defined Functions & Collating Sequences Full support for user-defined functions and collating sequences means that in many cases if SQLite doesn\'t

相关标签:
1条回答
  • 2020-11-30 02:27

    Robert Simpson has a great example of a REGEX function you can use in your sqlite queries:

    // taken from http://sqlite.phxsoftware.com/forums/p/348/1457.aspx#1457
    [SQLiteFunction(Name = "REGEXP", Arguments = 2, FuncType = FunctionType.Scalar)]
    class MyRegEx : SQLiteFunction
    {
       public override object Invoke(object[] args)
       {
          return System.Text.RegularExpressions.Regex.IsMatch(Convert.ToString(args[1]),Convert.ToString(args[0]));
       }
    }
    
    // example SQL:  SELECT * FROM Foo WHERE Foo.Name REGEXP '$bar'
    
    0 讨论(0)
提交回复
热议问题