User-259260637 posted
I have been trying to get the result from a query that looks like it is correct in the Output window but I can't seem to get the value, I always end up with the linq query,
var count = db.tblMemberBookings.Where(x => x.CourseDateId == courseId)
.GroupBy(x => new { x.NumberOfPlacesBooked, x.CourseDateId })
.Select(g => new { g.Key.NumberOfPlacesBooked, g.Key.CourseDateId, g = g.Count() }).FirstOrDefault();
courseId is a Guid and Number of Places is an Int.
This is what I get
count { NumberOfPlacesBooked = 1, CourseDateId = {4b0bc8cb-5adf-4943-9fa9-290a20d7f705}, g = 1 } <Anonymous Type>
How would I get the places booked into a variable that i could them query to know how many places have been booked and show the correct amount of places remaining.
Say course has 12 places - numberOfPlacesBooked
var count = db.tblMemberBookings.Where(x => x.CourseDateId == courseId)
.GroupBy(x => new { x.NumberOfPlacesBooked, x.CourseDateId })
.Select(g => new { g.Key.NumberOfPlacesBooked, g.Key.CourseDateId }).Count();
I solved it !!