public Person GetPerson(int id) { using (var context = new PeopleCarsDataContext(_connectionString)) { return(context.Persons.FirstOrDefault(p => p.Id == id)); } }
public void AddCar(Car car) { using (var context = new PeopleCarsDataContext(_connectionString)) { context.Cars.InsertOnSubmit(car); context.SubmitChanges(); } }
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. //} } }