コード例 #1
0
 public void Update(Person person)
 {
     using var context = new PeopleDbContext(_connectionString);
     context.People.Attach(person);
     context.Entry(person).State = EntityState.Modified;
     context.SaveChanges();
 }
コード例 #2
0
 public void Delete(int id)
 {
     using var context = new PeopleDbContext(_connectionString);
     context.Database.ExecuteSqlInterpolated($"DELETE FROM People WHERE Id = {id}");
 }
コード例 #3
0
 public void Add(Person person)
 {
     using var context = new PeopleDbContext(_connectionString);
     context.People.Add(person);
     context.SaveChanges();
 }
コード例 #4
0
 public List <Person> GetAll()
 {
     using var context = new PeopleDbContext(_connectionString);
     return(context.People.ToList());
 }