Embed Prepopulated SQL server db in Windows Phone app
This is a easy way to embed a Prepopulated SQL server database (read-only) into a Windows Phone app.
Include SDF into project at root level, mark it as “build-action: embed”
Using the SQL CE toolbox, generate a context class (http://sqlcetoolbox.codeplex.com/releases/view/104781), include this in your project.
Make a reference to system.data.linq
– I found I needed to comment out the lines containing “IDbConnection” but that might not be applicable.
Then the code for a select is simple:
using (dictContext db = new dictContext(“Data Source=appdata:/dict.sdf;File Mode=Read Only; Max Database Size = 512;”))
var translations = db.Dictionary.Where(d => d.Word == “CAT”);