C#.NET 中的 SQLite3

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1145190/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 09:17:44  来源:igfitidea点击:

SQLite3 in C#.NET

c#.netsqlitewrapper

提问by Zack

I'm trying to use SQLite3 in C#.NET. I've googled around and found some different API's. I also checked SQLite's website for wrappers. I like them, but want to write my own wrapper without using an added dependency. All wrappers I find that don't require an added dependency aren't free.

我正在尝试在 C#.NET 中使用 SQLite3。我在谷歌上搜索并找到了一些不同的 API。我还检查了 SQLite 的网站以获取包装器。我喜欢它们,但想在不使用附加依赖项的情况下编写自己的包装器。我发现不需要添加依赖项的所有包装器都不是免费的。

I'm wondering how one would read from, execute, and write to a sqlite3 database. Is it a socket connection(tcp? udp? etc?)?I've tried searching this answer on google and all I get are library-specific answers. :/ SQLite's website docs aren't much help either.

我想知道如何读取、执行和写入 sqlite3 数据库。它是套接字连接(tcp?udp?等?)?我试过在谷歌上搜索这个答案,我得到的只是特定于图书馆的答案。:/ SQLite 的网站文档也没有太大帮助。

EDIT:I also found a COM interfacewhile googling, but is that library specific?

编辑:我在谷歌搜索时也发现了一个COM 接口,但那个库是特定的吗?

Thanks SO! :)

谢谢!:)

采纳答案by Dillie-O

Have you looked at the System.Data.SQLitelibrary? It's a free ADO.NET library to interact with SQLite and requires nothing else in order to run, since it has the engine built into it.

你看过System.Data.SQLite库吗?它是一个免费的 ADO.NET 库,可以与 SQLite 交互,并且不需要其他任何东西就可以运行,因为它内置了引擎。

I've been using it for a while now and find it really easy to work with. It even has a plugin for Visual Studio should you decide to use some strongly-typed tables with it or want to use it to add/create tables.

我已经使用它一段时间了,发现它真的很容易使用。如果您决定使用一些强类型表或想要使用它来添加/创建表,它甚至还有一个 Visual Studio 插件。

回答by Philippe Leybaert

If you want to use SQLite in .NET, you should take a look at System.Data.SQLite, which is a ADO.NET provider for SQLite

如果你想在 .NET 中使用 SQLite,你应该看看System.Data.SQLite,它是 SQLite 的 ADO.NET 提供程序

回答by Jon Skeet

(Answering the "socket connection" question.)

(回答“套接字连接”问题。)

Part of the point of SQLite is that it's an embedded database - there's no server to talk to, you load the library directly into your process and it talks to the file system directly.

SQLite 的部分要点在于它是一个嵌入式数据库 - 没有可以与之通信的服务器,您可以将库直接加载到您的进程中,并且它直接与文件系统通信。

回答by Faraz

System.Data.SQLite is comparatively slower than other providers like SqlClient. I have look into its code.

System.Data.SQLite 比其他提供程序(如 SqlClient)要慢。我查看了它的代码。

Now I want to call it throw P/Invoke but not like SQLite provider. It call through P/Invoke every time when ever you access column value through DataReader

现在我想调用它 throw P/Invoke 但不像 SQLite provider。每当您通过 DataReader 访问列值时,它都会通过 P/Invoke 调用