In my Windows Mobile (.NET Compact Framework) application I use a big array to store the application's primary data. This is a dataset of potentially hundreds of objects. Each object has about 10 or so properties and two arrays of itself, each with about 25 other objects, each of which has about 5 properties.
To save this array on the mobile device, I simply serialize the entire array. This works well most of the time and it's very, very easy.
However in our test cases we always worked with only a handful of objects, a maximum of about 50 to 75. But our client has had cases where users had several hundreds of these objects, up to 1000. In those cases the serialization is quite slow, it can take up to a minute.
The actual problem is when saving the entire array, mostly only a couple of the objects have actually changed. So the basic flow is something like this:
- Load the entire array from storage, say 400 objects;
- Change a few properties of 1 object;
- Save the entire array back to storage, the full 400 objects;
- Change a couple more properties of that same object;
- Save again
- Change the final properties;
- Save again;
- Same with any subsequent objects...
It wouldn't be a problem normally if saving didn't occur too often, but on several intermediate steps the data is saved. This is to be sure all data is persisted and no data loss can occur (for example when the battery dies).
How can I solve this?