I’m using Sterling, a NoSQL database for .Net, Silverlight, and Windows Phone, to persist some data in a Silverlight 4 application. The intent is to persist it using Isolated Storage. It was obvious that the data was temporarily persisting because the stored data was available on multiple different views in the application. The trouble showed up when I stopped debugging and later started debugging again, the application re-launched and none of the previously persisted data was available.
Initially I was thinking that using the Visual Studio ASP.Net Development server was not maintaining Isolated Storage between application launches. It was far more simple than that. By default, Sterling uses an in-memory driver. If you want to persist using Isolated storage, you must pass an instance of the IsolatatedStorageDriver as an argument when Registering the Database. Note the difference in the samples below.
In Memory
Database = _engine.SterlingDatabase.RegisterDatabase<YourSterlingDatabase>();
Isolated Storage
Database = _engine.SterlingDatabase.RegisterDatabase<YourSterlingDatabase>(new Wintellect.Sterling.IsolatedStorage.IsolatedStorageDriver());
photo credit: Neil Noland / CC BY-SA 2.0
No comments:
Post a Comment