在System.Data.SQLite创建/使用用户定义的函数? [英] Create/Use User-defined functions in System.Data.SQLite?

查看:135
本文介绍了在System.Data.SQLite创建/使用用户定义的函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用户定义的函数和放大器;整理顺序
  用户定义的函数和整理顺序完全支持意味着在许多情况下,如果SQLite不具有的功能,你可以把它写自己在你最喜欢的.NET语言。写UDF的,并整理顺序从未如此简单

User-Defined Functions & Collating Sequences Full support for user-defined functions and collating sequences means that in many cases if SQLite doesn't have a feature, you can write it yourself in your favorite .NET language. Writing UDF's and collating sequences has never been easier

我发现在C# SQLite的ADO.NET 提供商升在这里找到该位,并有了解如何将文档问题实施/使用用户定义的函数。

I spotted this bit on the C# SQLite ADO.NET provider l found here, and was having problems understanding the documentation on how to implement/use user-defined functions.

谁能怎么解释,或提供任何工作实施这个失去新手?

Could anyone explain how to, or provide any working examples for this lost newbie?

推荐答案

罗伯特·辛普森你可以在你的sqlite查询使用正则表达式功能的一个很好的例子:

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'

这篇关于在System.Data.SQLite创建/使用用户定义的函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆