0
IBookingRepository bookingResp = new BookingRepository();
IQueryable<bookingTest> bookings = bookingResp.GetAllBookingsByView();
var grid = new System.Web.UI.WebControls.GridView();
grid.DataSource = from booking in bookings
join f in getallAttendees on booking.UserID equals f.UserID into fg
from fgi in fg.DefaultIfEmpty() //Where(f => f.EventID == booking.EventID)
where
booking.EventID == id
select new
{
EventID = booking.EventID,
UserID = booking.UserID,
TrackName = booking.Name,
BookingStatus = booking.StatusID,
AttendeeName = booking.FirstName,
// name = account.FirstName,
AmountPaid = booking.Cost,
AttendeeAddress = booking.DeliveryAdd1,
City = booking.DeliveryCity,
Postcode = booking.Postcode,
Date = booking.DateAdded,
hel = fgi == null ? null : fgi.HelmetsPurchased }// Product table
嗨,上面的查詢犯規執行它給出了一個錯誤:指定的LINQ表達式包含對與不同上下文關聯的查詢引用。任何人都可以發現查詢出現的問題。有遺留問題連接查詢LinqToSql
問題更新.. –
與會者和預訂是2個獨立的表,USERID是他們之間的外鍵 –
我明白了,但是如何獲得與會者?如果你希望能夠做你正在做的事情,你應該從同一個存儲庫中獲得它們,也就是說,而不是'getAllAttendees'你應該使用類似'bookingResp.Attendees'的東西。這樣,預訂和與會者應該來自同一個存儲庫和上下文。 –