System.Data.SQLite 扩展模型
我想用 C# 实现 System.Data.SQLite 的函数。实现SQLiteFunction
接口很容易(在互联网上查看示例)。
问题是我应该把编译后的代码放在哪里?我是否需要将源代码与 System.Data.SQLite 项目一起编译?我是否有更好的选择,以便我的函数驻留在单独的 DLL 中?
说明:该函数不仅应该为我的 C# 代码所知,而且为 sqlite3
客户端(例如)所知,因此我将能够在执行 INSERT 时使用它以纯文本形式出现的命令。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
SQLite 查看应用程序的所有程序集并识别具有
[SQLiteFunction]
属性的类型。因此,您可以将它们放在您喜欢的任何位置,只要在您第一次调用 SQLite 时该程序集已经加载即可。如果它只是一两个函数,我倾向于将它们放入应用程序的现有程序集中之一。
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.
有一个静态方法
SQLiteFunction.RegisterFunction
,但文档说它是......此外,据我所知,
SQLiteFunctionAttribute
的文档如下:和
所有用户定义的函数都会从所有加载的程序集中自动加载。
There's a static method
SQLiteFunction.RegisterFunction
, but documentation says that it's...Additionally, from what I can tell based on documentation to
SQLiteFunctionAttribute
:and
all user-defined functions are loaded automatically from all loaded assemblies.