MvvmCross - 如何在Windows商店后台任务访问的SQLite? [英] MvvmCross - how do I access SQLite in a windows store background task?

查看:176
本文介绍了MvvmCross - 如何在Windows商店后台任务访问的SQLite?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用mvvmcross sqlite的插件(社区版)商店的应用程序。这个程序有访问数据库获取数据的周期性后台任务在现场平铺显示。我不看我怎么可以从后台任务访问该数据库。我想用mvvmcross sqlite的插件在后台任务,但我不明白如何正确初始化mvvmcross环境。

I have a store app that uses the mvvmcross sqlite plugin (community edition). This app has a periodic background task that accesses the database to get data to be shown in a live tile. I can't see how I can get access to this database from the background task. I would like to use the mvvmcross sqlite plugin in the background task, but I don't see how to initialize the mvvmcross environment properly.

推荐答案

我能够解决一个简单的方法的问题。由于后台任务只需在PCL核心工程SQLite的数据服务,我做了以下内容:

I was able to solve the problem in a straightforward way. Since the background task only needed the SQLite data service from the PCL core project, I did the following:


  1. 包括对核心项目的引用。

  2. 增加了MvvmCross的的NuGet包和​​SQLite的社区插件。

  3. 删除的所有文件和文件夹做mvvmcross安装时补充:引导/,待办事项,Mvvmcross /,查看/,DebugTrace.cs和Setup.cs

  4. 有一个在的NuGet安装程序,需要一些额外的编辑项目文件来处理多个存储平台(X86,ARM和x64)的电流限制,请参见Cirrius.Mvvmcross.Community.Plugins.SQLite.WindowsStore需要平台特异性的dll对堆栈溢出X86和ARM了解详情。请确保你把选择语句的默认SQLite.WindowsStore参考后你需要离开在项目文件中的默认引用。您还需要根据位置来调整HintPath /你引用的名称。

  5. 通过显式调用工厂,创建数据服务的新实例初始化SQLite的数据服务:

  1. Included a reference to the Core project.
  2. Added the nuget packages for MvvmCross and the SQLite community plugin.
  3. Deleted all of the files and folders added when doing the mvvmcross install: Bootstrap/, Todo-Mvvmcross/, Views/, DebugTrace.cs, and Setup.cs.
  4. There is a current limitation in the nuget installer that requires some additional edits to the project file to handle multiple store platforms (x86, ARM, and x64), see 'Cirrius.Mvvmcross.Community.Plugins.SQLite.WindowsStore needs platform-specific dlls for X86 and ARM' on Stack Overflow for details. Make sure you put the Choose statement after the default SQLite.WindowsStore reference and you need to leave the default reference in the project file. You will also need to adjust the HintPath based on the location/names of your references.
  5. Initialized the SQLite data service by explicitly calling the factory and creating a new instance of the data service:

    var factory = new MvxStoreSQLiteConnectionFactory();
    IMyDataService repository = new MyDataService(factory);


我然后访问数据服务与mvvmcross相关联的其他开销。

I then have access to the data service with no other overhead associated with mvvmcross.

这篇关于MvvmCross - 如何在Windows商店后台任务访问的SQLite?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆