Reputation: 23
SELECT* FROM Event FULL OUTER JOIN Booking ON Event.eventId = Booking.eventId
WHERE(Booking.userId = 3) AND (Booking.bookingId IS NULL)
OR (Event.eventId IS NULL)
OR (Booking.eventId IS NULL)
This is what i have converted so far however i have encounter an error at "&& bookings.bookingId == null"
The error message is " Operator '&&' cannot be applied to operands of type 'int' and 'bool"
How do you fix it?
User student = (User)Session["user"];
var db = new EMS.Models.dbEMSEntities();
IQueryable<Event> query = from events in db.Events
join bookings in db.Bookings
on events.eventId equals bookings.eventId
where bookings.userId = student.userId
&& bookings.bookingId == null || events.eventId == null || bookings.eventId == null
Upvotes: 1
Views: 122
Reputation: 364
User student = (User)Session["user"];
var db = new EMS.Models.dbEMSEntities();
IQueryable<Event> query = from events in db.Events
join bookings in db.Bookings
on events.eventId equals bookings.eventId
where (bookings.userId == student.userId)
&& (bookings.bookingId == null) || (events.eventId == null) || (bookings.eventId == null)
Upvotes: 0
Reputation: 1536
where bookings.userId = student.userId && bookings.bookingId == null || events.eventId == null || bookings.eventId == null
is being evaluated as
where bookings.userId = (student.userId && bookings.bookingId == null) || events.eventId == null || bookings.eventId == null
Because of this, (int)userId && (bool)(bookingId == null) is comparing an int
against a bool
which violates the language
Make sure you use "==" as an evaluation and not the assignment "=".
Upvotes: 1