如何使用SQLite在Windows(手机)8.1的BackgroundTask [英] How to use SQLite in Windows (Phone) 8.1's BackgroundTask
问题描述
我跟着的通用的应用程序使用SQLite例如 以添加的SQLite
来我的项目;然后添加 BackgroundTask
我跟着的快速入门:创建并注册一个后台任务的例子
I followed Universal App with SQLite example to add SQLite
to my project; then to add the BackgroundTask
I followed Quickstart: Create and register a background task example.
-
SQLite的目标为
的Windows Phone 8.1
或的Windows 8.1
的 BackgroundTask
目标只有窗口
(是一个 Windows运行时组件
)
这是它变得棘手。
您不能引用与 BakgroundTask
不是的移动的,因而项目我不能添加 SQLite,让Windows运行时(Windows 8.1中)或< A HREF =https://visualstudiogallery.msdn.microsoft.com/5d97faf6-39e3-4048-a0bc-adde2af75d1b相对=nofollow> SQLite,让Windows Phone的8.1 到 BackgroundTask
项目。
You cannot reference a project with the BakgroundTask
that isn't portable, thus I cannot add SQLite for Windows Runtime (Windows 8.1) or SQLite for Windows Phone 8.1 to the BackgroundTask
project.
反正是有使用 SQLite的
在 BackgroundTask
?
推荐答案
有时候答案更容易超出预期。
Sometimes the answer is easier than expected.
- 设置后台任务的库目标只面向Windows(手机)8.1
- 创建一个
类库
的目标仅适用于Windows (手机)8.1 - 添加的SQLite的Windows(手机)8.1到
类库
- 引用
类库
通过后台任务
- Set the Background Task's Library Target to only target Windows (Phone) 8.1
- Create a
Class Library
that targets only Windows (Phone) 8.1 - Add SQLite for Windows (Phone) 8.1 to the
Class Library
- Reference the
Class Library
with the Background Task
这就是它!
完成大部分在类库
的工作,只进行从后台任务调用,这使得BGT看起来更干净。有关使用的好处一个类库
是,你可以使用泛型。
Do most of the work in the Class Library
and only make calls from the Background task, this makes the BGT look cleaner. The nice thing about using a Class Library
is that you can use generics.
您将有2个后台任务您普遍的应用程序
You will have 2 Background Tasks for your universal app
- Windows 8.1中后台任务
- 的Windows Phone 8.1后台任务
这篇关于如何使用SQLite在Windows(手机)8.1的BackgroundTask的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!