//Function: search reservations by keyword //Remarks: if the keyword == null, return all the records public List<Reservation> SearchReservationMatch(string keyword) { List<Reservation> reservationList = new List<Reservation>(); if (keyword == null) { keyword = "%"; } //search all the records else { } DataContextDataContext dc = new DataContextDataContext(); ISingleResult<search_current_reservation_by_keywordResult> rs = dc.search_current_reservation_by_keyword(keyword); foreach (search_current_reservation_by_keywordResult r in rs) { List<DishQuota> dishQuotaList = new List<DishQuota>(); ISingleResult<get_dishquota_by_reservationResult> rs2 = dc.get_dishquota_by_reservation(r.id); foreach (get_dishquota_by_reservationResult r2 in rs2) { double price = 0; ISingleResult<get_dish_by_nameResult> rs3 = dc.get_dish_by_name(r2.dish_name); foreach (get_dish_by_nameResult r3 in rs3) { price = (double)r3.price; } DishQuota tDishQuota = new DishQuota(r2.id, r2.dish_name, price, (int)r2.quato, r2.note); dishQuotaList.Add(tDishQuota); } Reservation reservation = new Reservation( r.id, r.user_from, r.customer_name, r.phone, (DateTime)r.arrive_time, r.table_name, (int)r.seat, (ReservationType)r.type, (ReservationState)r.state, dishQuotaList); reservationList.Add(reservation); } return reservationList; }