Esempio n. 1
0
 public void Add(People person)
 {
     using (var context = new PeopleCarsDbDataContext(_connectionString))
     {
         context.Peoples.InsertOnSubmit(person);
         context.SubmitChanges();
     }
 }
Esempio n. 2
0
 public void AddCar(Car c)
 {
     using (var context = new PeopleCarsDbDataContext(_connectionString))
     {
         context.Cars.InsertOnSubmit(c);
         context.SubmitChanges();
     }
 }
Esempio n. 3
0
 public IEnumerable <Car> GetCars(int personId)
 {
     using (var context = new PeopleCarsDbDataContext(_connectionString))
     {
         var loadOptions = new DataLoadOptions();
         loadOptions.LoadWith <Car>(c => c.People);
         context.LoadOptions = loadOptions;
         return(context.Cars.Where(c => c.PersonId == personId).ToList());
     }
 }
Esempio n. 4
0
 public IEnumerable <People> GetAll()
 {
     using (var context = new PeopleCarsDbDataContext(_connectionString))
     {
         var loadOptions = new DataLoadOptions();
         loadOptions.LoadWith <People>(p => p.Cars);
         context.LoadOptions = loadOptions;
         return(context.Peoples.ToList());
     }
 }