[英]SQL / Linq Join two tables and join date and time into single query
我有两个表如下所示。 SessionBooking.Date是日期字段,而TimeSlot.StartTime是时间字段。
表格架构:
您可以在下面看到当前查询,我已成功将两个表连接在一起,但是我需要将日期和开始时间连接到单个“ Datetime”字段中,以便我可以按日期时间(当前日期和时间)进行排序
我该怎么做,以及如何用Linq to SQL编写。
我到目前为止(不包括加入)
List<SessionBooking> bookings = db.SessionBookings.Where(m => m.MemberId == this.Id && m.LocationId == this.HomeLocationId && m.Date >= currentDate).OrderByDescending(m => m.Date).ThenBy(m => m.TimeSlot.StartTime).Take(limit).ToList();
试试这样的SELECT a.Date + b.time
从[eMart]。[dbo] .sessionBooking作为
join Timeslot as b on a.id = b.id
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.