Restore() performance on WP7

May 12, 2011 at 12:41 AM

I have a SL4 Out Of Browser app that builds a Sterling db and calls a Backup(). I am then taking that file and attempting to restore it inside a WP7 app. Currently, I am putting 10k records in the db, into a single table definition. For my example below, will use the Recipe model as an example.

  1. build and populate db in sl4
  2. call backup() (my documents)
  3. take resulting file and put it in a wp7 app as a 'Resource'
  4. use the following code to Restore():
    System.IO.Stream myFileStream = Application.GetResourceStream(new Uri(@"/MyApplication;component/", UriKind.Relative)).Stream;
    BinaryReader binaryReader = new BinaryReader(myFileStream);
    SterlingEngine _engine = new SterlingEngine();
    ISterlingDatabaseInstance _databaseInstance = _engine.SterlingDatabase.RegisterDatabase<RecipeDatabaseDefinition>();
    TraceHelper.Trace("Begin Restore");
    TraceHelper.Trace("End Restore");

 On the emulator, the restore took over a minute ( 1:11 ). On the device, it took over 12 minutes! (12:27). Ouch...

  • First, the following query worked just before I called backup() in the SL4 OOB app. It does not work just after the Restore() in the WP7 app, as if there is no data after the restore:
	int key = 99689;          
	Recipe recipeTest = _databaseInstance.Load<Recipe>(key);
  • The file the backup creates is 1.6mb. I have not even loaded all my data yet, nor all my table definitions. I am guessing the end result will be ~8mb. Is this a pipe dream?
  • Does 'restore' incrementally ask for more isolated storage? Is it possible to have it start out with what I think it will need?
  • Any suggestions? Is a Stream from Resource a good idea? Better ways?