开发者

Problems with Left join Query LinqToSql

      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 

Hi, the above query doesnt executes it gives an error: The specified LINQ expression contains references to queries that are associated with different contexts. Any one can spot the what the problem is with the query.


I think that your getAllAttendees is from a different context than bookings so you won't be able to join them. To give a more exact answer you need to show where bookings and getAllAttendees comes from.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜