1

我的 Windows Phone 8 应用程序 (C#/XAML/SQLite) 在我将它作为“测试版”在 Windows 商店中发布然后安装到我的智能手机 (Lumia 620) 之后运行非常缓慢。那些“冻结”是我的应用程序执行选择到 sqlite 数据库文件的地方。在没有数据库查询的页面上,一切都很完美。所以我认为情况就是这样。

我不明白的是,当我从 Visual Studio 部署应用程序时,具有完全相同设置的应用程序可以正常工作。

我使用 nokia.com 上本主题中所述的 sqlite - http://developer.nokia.com/Community/Wiki/How_to_use_SQLite_in_Windows_Phone

我的解决方案中有 c++ sqlite 项目和 sqlite-net 包中的两个文件(SQLite.cs 和 SQLiteAsync.cs)

构建配置是“Release”,平台是“ARM”。

数据库查询示例:

using MyApp.Model.Entities;
using System.Collections.Generic;

namespace MyApp.DAL
{
    public class MyAppRepository
    {
        private string dbPath = @"Assets/words.db";

        public List<Word> GetWordsByCatId(int id)
        {
            var sql = string.Format(@"
SELECT w.[id],
       w.[word_en],
       w.[word_ru]
  FROM words w INNER JOIN word_links l ON w.[id]=l.[word]
 WHERE l.category = {0};", id);

            using (var conn = new SQLite.SQLiteConnection(dbPath))
            {
                var list = conn.Query<Word>(sql);
                return list;
            }
        }

        public List<Cat> GetCats2()
        {
            var sql = string.Format(@"
SELECT c.[id],
       c.[name_en],
       c.[name_ru],
       COUNT(l.[id]) words
  FROM categories c
    LEFT JOIN word_links l ON c.[id]=l.[category]
 GROUP BY c.[id]
HAVING words>1;");

            using (var conn = new SQLite.SQLiteConnection(dbPath))
            {
                var list = conn.Query<Cat>(sql);
                return list;
            }
        }

        public List<Cat> GetCatsByWordId(int id)
        {
            var sql = string.Format(@"
SELECT c.[id],
       c.[name_en],       
       c.[name_ru]
  FROM categories c INNER JOIN word_links l ON c.[id]=l.[category]
 WHERE l.word = {0};", id);

            using (var conn = new SQLite.SQLiteConnection(dbPath))
            {
                var list = conn.Query<Cat>(sql);
                return list;
            }
        }
    }
}
4

0 回答 0