在 Windows Phone 8 中使用 SQLite - 关系和查询 [英] Using SQLite in Windows Phone 8 - relations and queries

查看:36
本文介绍了在 Windows Phone 8 中使用 SQLite - 关系和查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 Windows Phone 8 应用程序 (C#),它将使用 SQLite 和本机包装器.我已经设置并运行了它,但是除了如何下载它和添加基本表之外,我还没有找到太多文档.因此,我有几个问题:

I am working on a Windows Phone 8 App (C#) that will use SQLite with the Native wrapper. I have it set up and working, but I haven't found much documentation except how to download it and add basic tables. Therefore, I have a few questions:

  1. 有没有办法指定对象之间的关系?
  2. 是否可以使用 QueryAsync() 方法进行复杂的 SQL 查询?我想做一个连接多个表的查询,并使用 LIKE 运算符来搜索匹配的条目.

谢谢

推荐答案

我假设你正在使用 SQLite-net 以及 SQLite-net-wp8 用于 wp8 中的本机 SQLite 访问.

I am assuming you are using SQLite-net along with SQLite-net-wp8 for native SQLite access in wp8.

有没有办法指定对象之间的关系?

Is there any way to specify relations between objects?

不幸的是没有.但是,您可以在外键上指定 [Indexed] 属性以提高性能.当然,您始终可以使用 SQL 脚本预先构建您的表,在这种情况下,您可以指定关系.

Unfortunately no. However, you can specify [Indexed] attribute on your foreign keys for performance. Of course, you can always pre-build your tables using SQL scripts in which case you can specify relations.

是否可以使用 QueryAsync() 进行复杂的 SQL 查询方法?我想做一个连接多个表的查询用于搜索匹配条目的 LIKE 运算符.

Is it possible to do Complex SQL queries using the QueryAsync() method? I would like to do a query that joins multiple tables and does a LIKE operator to search for matching entries.

您可以构建复杂的查询,但您必须为连接执行 SQL 脚本,因为该库尚不支持.

You can build complex queries but you have to execute SQL scripts for joins as the library doesn't support that yet.

string myQuery = "....";
var result = await db.QueryAsync<MyTableType>(myQuery, myParams);

这篇关于在 Windows Phone 8 中使用 SQLite - 关系和查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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