コード例 #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());
     }
 }
コード例 #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());
         //ISingleResult<GetPeopleAndCarCountResult> result = context.GetPeopleAndCarCount();
         //foreach (GetPeopleAndCarCountResult item in result)
         //{
         //    item.
         //}
     }
 }