public void InsertArrivalTimes(IEnumerable<ArrivalTimeData> arrivalTimes) { using (var database = new DataClassesDataContext()) { foreach (var arrivalTime in arrivalTimes) { var result = new ArrivalTime(); database.ArrivalTimes.InsertOnSubmit(result); var restaurant = database.Restaurants.FirstOrDefault(r => r.Name == arrivalTime.Restaurant.Name); if (restaurant == default(Restaurant)) { restaurant = new Restaurant(); restaurant.Name = arrivalTime.Restaurant.Name; database.Restaurants.InsertOnSubmit(restaurant); } result.Restaurant = restaurant; result.TimeArrived = arrivalTime.TimeArrived; database.ArrivalTimes.InsertOnSubmit(result); } database.SubmitChanges(); } }
partial void UpdateRestaurant(Restaurant instance);
partial void DeleteRestaurant(Restaurant instance);
partial void InsertRestaurant(Restaurant instance);