Пример #1
0
 public Person GetPerson(int id)
 {
     using (var context = new PeopleCarsDataContext(_connectionString))
     {
         return(context.Persons.FirstOrDefault(p => p.Id == id));
     }
 }
Пример #2
0
 public void AddCar(Car car)
 {
     using (var context = new PeopleCarsDataContext(_connectionString))
     {
         context.Cars.InsertOnSubmit(car);
         context.SubmitChanges();
     }
 }
Пример #3
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());
     }
 }
 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());
         //ISingleResult<GetPeopleAndCarCountResult> result = context.GetPeopleAndCarCount();
         //foreach (GetPeopleAndCarCountResult item in result)
         //{
         //    item.
         //}
     }
 }