用于 UWP 的 sqlite-net

sqlite-net for UWP

我正在测试 SQLite.net 我的 UWP 10 应用程序。我已将通用 Windows 平台的 SQLite 扩展(即所需的 .vsix)添加到我的项目中作为参考。 我也从 nuget 安装了 sqlite-net nuget 包。

但是我无法在我的项目中添加对 SQLite -net 函数的引用。我也看不到任何额外的 SQLite.cs 或 SQLiteAsync.cs 添加到项目中。 我需要一些额外的配置吗?

还有 SQLite.Net-PCL 比 sqlite-net.If 好吗?

UWP 应用程序的 Nuget 包不允许您向项目添加代码文件。您将需要 SQLite。Net-PCL 或 entity framework 7 RC(即将成为 Enityframework 核心 1.0)

向您的项目添加参考 SQLite SDK 参考并安装 SQLite.NET PCL 包是您所需要的。您现在应该可以访问 SQLiteConnection 和所有其他 类.

看看这篇逐步描述该过程的文章:http://blogs.u2u.be/diederik/post/2015/09/08/Using-SQLite-on-the-Universal-Windows-Platform.aspx

我在 UWP 应用程序中使用 SQLite.Net-PCL 和 SQLite.Net.Async-PCL 时效果很好。

这就是我使用这两个包的方式:

  • 从 Nuget
  • 安装 SQLite.Net-PCL 包和 SQLite.Net.Async-PCL
  • 从"tool"中选择"Extensions and Updates...",在"Online"中搜索"sqlite",找到"SQLite for Universal App Platform"并安装。
  • 右键单击项目的 References,选择 "Add Reference",然后添加 "SQLite for Universal App Platform"。

这是我昨天写的IncrementalLoadingWithSQLite sample,文件有点大,因为我在这个项目中有600多张图片。

不要忘记添加所需的引用。我一开始也犯了同样的错误...

using SQLite.Net;
using SQLite.Net.Platform.WinRT;
using Windows.Storage;

最后一个用于获取 SQLite 数据库在应用程序本地文件夹中的存储路径。 其他参考资料,例如

using System.Data.Common;
using SQLite.Net.Attributes;

你想用应用程序上的数据库做的其他事情将需要..