public override void InsertFile(UploadedFile entity) { if (entity == null) throw new ArgumentNullException("entity"); entity.ApplicationName = this.ApplicationName; using (var db = new SqlUploadStorageContext(this.ConnectionStringName)) { db.UploadedFiles.Add(entity); db.SaveChanges(); } }
public override void UpdateFile(UploadedFile entity) { if (entity == null) throw new ArgumentNullException("entity"); using (var db = new SqlUploadStorageContext(this.ConnectionStringName)) { db.UploadedFiles.Attach(entity); var entry = db.Entry(entity); entry.State = EntityState.Modified; db.SaveChanges(); } }
public override void DeleteFile(UploadedFile entity) { if (entity == null) throw new ArgumentNullException("entity"); using (var db = new SqlUploadStorageContext(this.ConnectionStringName)) { var item = db.UploadedFiles.Find(entity.ID); if (item == null) return; db.UploadedFiles.Remove(item); db.SaveChanges(); } }