コード例 #1
0
        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();
            }
        }
コード例 #2
0
 partial void UpdateRestaurant(Restaurant instance);
コード例 #3
0
 partial void DeleteRestaurant(Restaurant instance);
コード例 #4
0
 partial void InsertRestaurant(Restaurant instance);