Windows手机Sqlite不会返回有效查询的结果

时间:2015-03-08 13:14:05

标签: sqlite windows-phone-8

我有一个查询,我直接测试sqlite并且工作正常,但在windows phone 8 app中使用它时,不会返回结果

 string sqlCommandText = "select  a.article_id  article_id, a.book_hierarchy_id  book_hierarchy_id,  b.title  title , b._ID  _ID , b.articles_count  articles_count, b.saved_articles_count  saved_articles_count, b.hierarchy_id  hierarchy_id, b.downloaded_articles_count   downloaded_articles_count " +
                                    "from  hierarchy_articles a inner join book_hierarchy b on b.book_hierarchy_id = a.book_hierarchy_id " +
                                    "where a.book_id = " + bookID + " and a.book_hierarchy_id > " + Consts.HadithKotobsCount + "  order by a.article_id";
            using (SQLiteConnection conn = new SQLite.SQLiteConnection(Consts.DBPath))
            {
                SQLiteCommand sqlCommand = new SQLiteCommand(conn);
                sqlCommand.CommandText = sqlCommandText;

                List<HadithIndexTemp> babs2 = sqlCommand.ExecuteQuery<HadithIndexTemp>();

            }

这里是映射类型

public class HadithIndexTemp
    {
        public int article_id { get; set; }
        public int book_hierarchy_id { get; set; }
        public string title { get; set; }

        public int _ID { get; set; }
        public int articles_count { get; set; }
        public int saved_articles_count { get; set; }
        public int hierarchy_id { get; set; }
        public int downloaded_articles_count { get; set; }

}

更新: 这个问题是由&#34;命令引起的。部分删除它,它工作正常

1 个答案:

答案 0 :(得分:0)

你可以像这样使用它:

using (SQLiteAsyncConnection conn = new SQLiteAsyncConnection(Consts.DBPath))
{
    var result = conn.QueryAsync<HadithIndexTemp>(sqlCommandText).Result;
}