This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I have a LINQ query that worked fine, until I tried to add a count function into it. Now I recieve a Count() not support in LINQ Lightspeed error message. Can anyone please suggest a workaroud that might work. My LINQ in below, the line with the problem is highlighted. var bkngs = from b in uow.HotelBookings.Where(x => x.RoomTypeId == roomTypeId var tmplist = new BindingList<HotelRoomCalendarSearch>(bkngs.ToList()); The problem line highlighted with ***** is join r in uow.HotelRooms.Where(hr => hr.HotelRoomAmenities.Count(hra => hra.Amenity == Amenity1.Amenity) > 0) on b.RoomId equals r.Id into z What I am trying to do is limit the HotelRooms collection to rooms that contain a record in the joined collection, HotelRoomAmenities, that matches a passed string value, i.e. Amenity1.Amenity. But LINQ for lightspeed does not seem to support this functionality. Can anyone suggest another way to do this? I have been looking at this for a while, and I am loosing my mind over it. Thanks in advance to all helpers.
|
|
|
Hi Mark, Count() (and other SQOs) are not supported as criteria in LightSpeed, so having them in the Where clause is what is causing the error. Rather than filtering based on the Where approach, try joining the HotelRoomAmenities and then filter directly against that, e.g. join hrm in uow.HotelRoomAmeneties on r.Id equals hrm.HotelId ... where hrm.Amenity == Amenity1.Amenity
Jeremy |
|