Esempio n. 1
0
 public void Update(Person person)
 {
     using var context = new PeopleDataContext(_connectionString);
     context.People.Attach(person);
     context.Entry(person).State = EntityState.Modified;
     context.SaveChanges();
 }
Esempio n. 2
0
        public void Delete(List <int> ids)
        {
            using var context = new PeopleDataContext(_connectionString);
            var peopleToDelete = context.People.Where(p => ids.Contains(p.Id));

            context.People.RemoveRange(peopleToDelete);
            context.SaveChanges();
        }
Esempio n. 3
0
 public void Add(Person person)
 {
     using var context = new PeopleDataContext(_connectionString);
     context.People.Add(person);
     context.SaveChanges();
 }