Sterling queries may reference cached data

Explore practical solutions to optimize last database operations.
Post Reply
surovy113
Posts: 29
Joined: Sat Dec 21, 2024 9:35 am

Sterling queries may reference cached data

Post by surovy113 »

Sterling is an ideal solution for tombstoning Windows Phone 7 applications. See 3. The Sterling Engine for a tip and example of hooking into the Windows Phone 7 events. When creating applications for the phone, consider using settings to store relevant keys that pertain to data in view models, then use Sterling to load the data with the persisted keys.

Derived Types


Sterling handles interfaces and base classes without issue because Sterling will always serialize the concrete type. However, it is tempting to try to define a base type as a Person class, for example, and then implement Student and Teacher that dervie from person.

Sterling will handle this better if it is managed like a traditional database, where the domain may identify common attributes for a base class but the database defines distinct tables. Because Sterling serializes the concrete type, it will "miss" a base email database definition and fail to serialize the object as a referenced table. Instead, define separate tables for Student and Teacher to keep them partitioned in storage. You will introduce no additional overhead, and Sterling will still recognize the tables and handle them appropriately even if you store them on your host type as type Person.

Image

Rollback / Pseudo-Transaction Support


While the Load function always loads the latest from disk irrespective of cache. If you wish to perform a rollback, then you can simply store the older value in a separate variable before performing your transaction. If some condition triggers the need to rollback, you can simply save the original value back.

The type master should also be saved (see the note in the b. Database Backup and Restore section). In the distributed application, the database is queried and if it is empty, the flow is directed to a page to handle the restore. Restores can take significant time, especially on the phone, due to the slower speed of isolated storage, so it is recommended that you provide a dialog to the user to indicate you are restoring the database. The database is restored, then the database shut down and the type master restored. Now the engine can be activated again and the database should be ready to use.

On the Windows Phone 7 there is a risk that tombstoning can occur during the restore. For this case, it is suggested you write a value to isolated storage or to application settings to indicate the restore is complete. If the setting does not exist, you always assume the database must be restored. Only when the complete restore succeeds will you set the flag to indicate the application is ready.
Post Reply