55712

Using SQLite in Windows Phone 8 - relations and queries

Question:

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:

<ol><li>Is there any way to specify relations between objects?</li> <li>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.</li> </ol>

Thanks

Answer1:

I am assuming you are using <a href="https://github.com/praeclarum/sqlite-net" rel="nofollow">SQLite-net</a> along with <a href="https://github.com/peterhuene/sqlite-net-wp8" rel="nofollow">SQLite-net-wp8</a> for native SQLite access in wp8.

<blockquote>

Is there any way to specify relations between objects?

</blockquote>

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.

<blockquote>

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.

</blockquote>

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

<pre class="lang-cs prettyprint-override">string myQuery = "...."; var result = await db.QueryAsync<MyTableType>(myQuery, myParams);

Recommend

  • How to get not only single record but all records that belong to specific search query
  • Loopback API include filters not working as expected
  • Yii: how to show a field from a related table's related table?
  • Models with two hasOne relations to same table
  • EventLog logs in Application, even though set to another log
  • Have anyone succeeded in ThinApp'ing Visual Studio?
  • git push origin master denied to user X where x is NOT the user in the local git config
  • Swift string variables localization
  • ASP.NET, C# How to Pass a StringQuery to a custom SQL Command
  • How to use ResourceDictionary in Windows Phone class library project
  • TSQL Rolling Average of Time Groupings
  • Are there any side effects from calling SQLAlchemy flush() within code?
  • Regex for Specific Tag
  • Cypher - matching two different possible paths and return both
  • MySQL performance when updating row with FK
  • How can I get the choice “H2” back in the H2 consol?
  • How do I shift the decimal place in Python?
  • pyodbc doesn't report sql server error
  • Not able to aggregate on nested fields in elasticsearch
  • Date Conversion from yyyy-mm-dd to dd-mm-yyyy
  • Debug.DrawLine not showing in the GameView
  • Swift: Switch statement fallthrough behavior
  • Google Custom Search with transparent background
  • Django: Count of Group Elements
  • PHPUnit_Framework_TestCase class is not available. Fix… - Makegood , Eclipse
  • CSS Linear-gradient formatting issue accross different browsers
  • Insert into database using onclick function
  • What is Eclipse's Declaration View used for?
  • PHP - How to update data to MySQL when click a radio button
  • Counter field in MS Access, how to generate?
  • Is possible to count alias result on mysql
  • Can I make an Android app that runs a web view in Chrome 39?
  • Trying to switch camera back to front but getting exception
  • Calling of Constructors in a Java
  • Free memory of cv::Mat loaded using FileStorage API
  • Angular 2 constructor injection vs direct access
  • What are the advantages and disadvantages of reading an entire file into a single String as opposed
  • Programmatically clearing map cache
  • costura.fody for a dll that references another dll
  • Python/Django TangoWithDjango Models and Databases