public void UploadMorpherCache(List <KeyValuePair <string, MorpherCacheObject> > cache) { List <KeyValuePair <string, MorpherCacheObject> > pairs = cache.Select( pair => new KeyValuePair <string, MorpherCacheObject>(pair.Key, (MorpherCacheObject)pair.Value)).ToList(); string serializedCache = Gzip.Zip(JsonConvert.SerializeObject(pairs)); using (CompressedCacheDataContext context = new CompressedCacheDataContext()) { var result = context.CompressedCaches.FirstOrDefault( compressedCache => compressedCache.Date == DateTime.Now.Date); if (result != null) { result.GZipCache = serializedCache; } else { context.CompressedCaches.InsertOnSubmit(new CompressedCache() { Date = DateTime.Now.Date, GZipCache = serializedCache }); } context.SubmitChanges(); } }