Пример #1
0
 public void Delete(int personId)
 {
     using (var context = new PeopleDataContext(_connectionString))
     {
         context.ExecuteCommand("DELETE FROM People Where Id = {0}", personId);
     }
 }
Пример #2
0
 public IEnumerable <Person> GetAll()
 {
     using (var context = new PeopleDataContext(_connectionString))
     {
         return(context.Persons.ToList());
     }
 }
Пример #3
0
 public void Add(Person person)
 {
     using (var context = new PeopleDataContext(_connectionString))
     {
         context.Persons.InsertOnSubmit(person);
         context.SubmitChanges();
     }
 }
Пример #4
0
 public void Update(Person person)
 {
     using (var context = new PeopleDataContext(_connectionString))
     {
         context.Persons.Attach(person);
         context.Refresh(RefreshMode.KeepCurrentValues, person);
         context.SubmitChanges();
     }
 }