1
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,
product = fgi == null ? null : fgi.productPurchased
};
Booking
表设计:与LINQ到SQL问题联接查询
ID, EventID, UserID, BookingStatus, AmountPaid, AttendeeAddress, City, Date
Product
表设计:
预订和产品表之间的关联是多对多和外键是UserID
上面的Linq-to-SQL查询re只转换booking.UserID equals att.UserID
的用户的数据,我想要的是将该特定事件的所有用户也返回给苹果和香蕉字段,如果他们购买了其他字段,则在该列中填写空值。
任何可能的解决方案或例子将高度赞赏。
OK,让我试试吧 –
仍然得到指定的LINQ表达式包含对与不同上下文关联的查询引用。错误 –
我们将需要看到更新的查询与错误消息 – Aducci