Example #1
0
 public Person GetPerson(int id)
 {
     using (var context = new PeopleCarsDataContext(_connectionString))
     {
         return(context.Persons.FirstOrDefault(p => p.Id == id));
     }
 }
Example #2
0
 public void AddCar(Car car)
 {
     using (var context = new PeopleCarsDataContext(_connectionString))
     {
         context.Cars.InsertOnSubmit(car);
         context.SubmitChanges();
     }
 }
Example #3
0
 public void AddPerson(Person person)
 {
     using (var context = new PeopleCarsDataContext(_connectionString))
     {
         context.Persons.InsertOnSubmit(person);
         context.SubmitChanges();
     }
 }
Example #4
0
        public IEnumerable <Person> GetPeople()
        {
            using (var context = new PeopleCarsDataContext(_connectionString))
            {
                var loadOptions = new DataLoadOptions();
                loadOptions.LoadWith <Person>(p => p.Cars);
                context.LoadOptions = loadOptions;

                return(context.Persons.ToList());
            }
        }