Im using the PersistenceManager with the xamGrid and all works fine, however the performance isnt great. It takes quite a long time to save the data using a memorystream and the actual stream itself is quite large (over 2MB). As this information is likely to be stored in a central database I need to minimize the size of this and improve the performance.
Is there anyway to reduce the size of the persisted value and improve the performance?
Thanks,Doug
Because I had the same problem, i.e.wanting to store the PM settings in the database and data size being too large, I looked at using the compression library as suggested by Devin.
24 hours later, I think I better share the solution that I thought would take only 10 minutes to devise. It might save someone in the same situation a lot of time, as the compression and decompression was not as straightforward as expected.
I am using a PersistenceGroup object for saving the settings from, and the settings get applied to this group after retrieval from the database.
public static byte[] ExtractReportSettingAsBinary(
PersistenceGroup inPersistenceGroup)
{
using (MemoryStream memoryStream =
PersistenceManager.Save(inPersistenceGroup))
using (MemoryStream compressed = new MemoryStream())
using(DeflateStream compressor = new DeflateStream(
compressed,
CompressionMode.Compress,
CompressionLevel.BestCompression))
memoryStream.CopyTo(compressor);
}
// Must close compressor
// to force flushing of remaining data!
byte[] retVal = compressed.ToArray();
return retVal;
public static void ApplyReportSetting(
ref PersistenceGroup ioPersistenceGroup,
byte[] data)
using (Stream dataStream = new MemoryStream(data))
using (MemoryStream memoryStream = new MemoryStream())
using (DeflateStream decompressor = new DeflateStream(
dataStream,
CompressionMode.Decompress))
decompressor.CopyTo(memoryStream);
// Must close decompressor
// Reset. Very important, as stream is at end after
// decompressor used it!
memoryStream.Position = 0;
// Now apply back to our report
PersistenceManager.Load(ioPersistenceGroup, memoryStream);
Couple of suggestions on reducing the size of the PM oputput:
1) Persistance Manager allows you to control exactly what properties are saved using its PersistanceSettings API. You might use this to more tightly control which grid properties you want/don't want persisted:
https://es.infragistics.com/samples/silverlight/grid/overview
2) The PM basically produces an XML file, so you could look at running that through our compression library to compress the output before you save the stream:
http://help.infragistics.com/Doc/Silverlight/2010.3/CLR4.0/?page=InfragisticsSL4.Compression.v10.3~Infragistics.Compression.DeflateStream.html
Hope that helps.
Devin
Actually I discovered if you set the itemsource to null then reload from the PM then reset the itemsource to the actual data the performance is fine.
The size is still a bit large, but if there is no alternative to reduce the size I will put up with it.
Regards,Doug