开发者

System.Data.SQLite extension model

I want to implement a function for System.Data.SQLite in C#. Implementing the SQLiteFunction interface is easy (seen examples over the Internet).

The question is where should I put the compiled code? Do I need the source to be compiled altogether with the System.Data.SQLite project? Do I have a better option, so that my functions will reside in a separate DLL?

Clarification: The function is supposed to be known not only for my C# code but also for sqlite3 client (for example), so I will be able to 开发者_运维技巧use it while executing INSERT commands that come in plain text.


SQLite looks at all of your application's assemblies and recognises types that have the [SQLiteFunction] attribute. So you can put them wherever you like, as long as that assembly is already loaded by the time you make your first SQLite call.

If it's just one or two functions I'd be inclined to put them in one of your application's existing assemblies.


There's a static method SQLiteFunction.RegisterFunction, but documentation says that it's...

...a workaround for the Compact Framework where enumerating assemblies is not currently supported.

Additionally, from what I can tell based on documentation to SQLiteFunctionAttribute:

A simple custom attribute to enable us to easily find user-defined functions in the loaded assemblies and initialize them in SQLite as connections are made.

and

Using reflection, enumerate all assemblies in the current appdomain looking for classes that have a SQLiteFunctionAttribute attribute, and registering them accordingly.

all user-defined functions are loaded automatically from all loaded assemblies.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜