Exemplo n.º 1
0
 public void Add(People person)
 {
     using (var context = new PeopleCarsDbDataContext(_connectionString))
     {
         context.Peoples.InsertOnSubmit(person);
         context.SubmitChanges();
     }
 }
Exemplo n.º 2
0
 public void AddCar(Car c)
 {
     using (var context = new PeopleCarsDbDataContext(_connectionString))
     {
         context.Cars.InsertOnSubmit(c);
         context.SubmitChanges();
     }
 }
Exemplo 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());
     }
 }
Exemplo 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());
     }
 }