Ejemplo n.º 1
0
 public IList <Note> GetAllNotes()
 {
     using (var db = new NoteContext(_connectionString))
     {
         return(db.Notes.ToList());
     }
 }
Ejemplo n.º 2
0
        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();
            }
        }
Ejemplo n.º 3
0
 public SqlNoteRepository()
 {
     using (var db = new NoteContext(_connectionString))
     {
         if (!db.DatabaseExists())
         {
             db.CreateDatabase();
         }
     }
 }
Ejemplo n.º 4
0
 public void Add(string title, string contents)
 {
     using (var db = new NoteContext(_connectionString))
     {
         db.Notes.InsertOnSubmit(
             new Note
         {
             Title    = title,
             Contents = contents
         });
         db.SubmitChanges();
     }
 }