public void TestUpdate()
        {
            ImageRecord ir;
            using (ZumpaDB db = new ZumpaDB())
            {
                ir = new ImageRecord { File = "File", Link = "Link", Size = 12345, IsValid = true };
                db.Images.InsertOnSubmit(ir);
                db.SubmitChanges();
            }

            using (ZumpaDB db = new ZumpaDB())
            {
                ir = db.Images.Where(e => "File".Equals(e.File)).SingleOrDefault();
                Assert.IsNotNull(ir);
                ir.IsValid = false;
                db.SubmitChanges();
            }

            using (ZumpaDB db = new ZumpaDB())
            {
                ir = db.Images.Where(e => "File".Equals(e.File)).FirstOrDefault();
                Assert.IsFalse(ir.IsValid);
                db.Images.DeleteOnSubmit(ir);
                db.SubmitChanges();
            }
        }
        public ImageLoader()
        {
            if (System.ComponentModel.DesignerProperties.IsInDesignTool) return;

            _storage = IsolatedStorageFile.GetUserStoreForApplication();
            _database = new ZumpaDB();
            _cache = LoadMemoryCache();
        }
 private static ZumpaDB CreateDatabaseIfNecessary()
 {
     ZumpaDB db = new ZumpaDB(DBConnectionString);
     if (!db.DatabaseExists())
     {
         db.CreateDatabase();
     }
     return db;
 }
 static ZumpaDB()
 {
     _instance = CreateDatabaseIfNecessary();
 }
        /// <summary>
        /// Get simple stastics about free/downloaded data
        /// </summary>
        /// <returns></returns>
        public static StorageValues GetStorageValues()
        {
            StorageValues values = new StorageValues();

            using (var storage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                values.FreeSpace = storage.AvailableFreeSpace;
            }
            using (var db = new ZumpaDB())
            {
                if (db.Images.Count() > 0)
                {
                    values.Downloaded = db.Images.Sum(e => e.Size);
                }
            }
            return values;
        }