我在使用带有 LINQ 的 foreach 循环时遇到了一些问题,这是我到目前为止所拥有的代码,我正在尝试获取与特定预订相关的客户列表,任何帮助将不胜感激 =]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
namespace BookingCustomers
{
public partial class BookingGuests : System.Web.UI.Page
{
private HotelConferenceEntities datacontext = new HotelConferenceEntities();
private void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
try
{
int id = int.Parse(BookID.Text.ToString());
tblBooking booking = datacontext.tblBookings.SingleOrDefault(x => x.BookingID == id);
tblVenue venue = datacontext.tblVenues.SingleOrDefault(x => x.VenueID == booking.Venue);
List<tblCustomer> customers = new List<tblCustomer>();
List<tblBookingGuest> guests = booking.tblBookingGuests.ToList();
foreach (list<tblBookingGuest> in tblBookingGuest)
{
}
}