Exemple #1
0
 public void DeleteCars(int personId)
 {
     using var contex = new PeopleCarsContext(_connectionString);
     contex.Database.ExecuteSqlInterpolated($"DELETE FROM Cars WHERE PersonId = {personId}");
 }
Exemple #2
0
 public void AddCar(Car car)
 {
     using var context = new PeopleCarsContext(_connectionString);
     context.Cars.Add(car);
     context.SaveChanges();
 }
Exemple #3
0
 public List <Car> GetCarsForPerson(int personId)
 {
     using var context = new PeopleCarsContext(_connectionString);
     return(context.Cars.Where(c => c.PersonId == personId).ToList());
 }
Exemple #4
0
 public Person GetPerson(int id)
 {
     using var context = new PeopleCarsContext(_connectionString);
     return(context.People.FirstOrDefault(p => p.Id == id));
 }
Exemple #5
0
 public List <Person> GetPeople()
 {
     using var context = new PeopleCarsContext(_connectionString);
     return(context.People.Include(c => c.Cars).ToList());
 }
Exemple #6
0
 public void AddPerson(Person person)
 {
     using var context = new PeopleCarsContext(_connectionString);
     context.People.Add(person);
     context.SaveChanges();
 }