You need to end your query with a select clause – and I think your rent period start time comparison is the wrong way round, unless I’ve misunderstood you – but I would also convert your whole query into the query syntax rather than the mix you have, e.g.
var parkingspot = from Address in _parkShareDbContext.Addresses
join ParkingSpot in _parkShareDbContext.ParkingSpots on Address.Id equals ParkingSpot.Address.Id
join RentPeriod in _parkShareDbContext.RentPeriods on ParkingSpot.Id equals RentPeriod.ParkingSpotId
where ParkingSpot.Active
&& (size == null || ParkingSpot.Spotsize == size)
&& RentPeriod.Type == periodType
&& !RentPeriod.IsRentedOut
&& RentPeriod.RentPeriodStart >= realStartTime
select RentPeriod;
EDIT
However, as per the comments above, with complex queries like this one, you are usually better off writing a parameterised SQL query, or using a stored procedure to fetch data.
I’m also not sure why you need Address
in there?
CLICK HERE to find out more related problems solutions.