public IList <Note> GetAllNotes() { using (var db = new NoteContext(_connectionString)) { return(db.Notes.ToList()); } }
public void Delete(long id) { using (var db = new NoteContext(_connectionString)) { var noteToDelete = db.Notes.First(note => note.Id == id); db.Notes.DeleteOnSubmit(noteToDelete); db.SubmitChanges(); } }
public SqlNoteRepository() { using (var db = new NoteContext(_connectionString)) { if (!db.DatabaseExists()) { db.CreateDatabase(); } } }
public void Add(string title, string contents) { using (var db = new NoteContext(_connectionString)) { db.Notes.InsertOnSubmit( new Note { Title = title, Contents = contents }); db.SubmitChanges(); } }