我在下面有这个 sql 查询,我必须使用 linq 来实现它,但我无法为它创建一个 linq 语句。请提供一些帮助。
Declare @DateTime datetime
set @DateTime = '06/20/2012';-- To get the yesterday/any day attendance record.
With Cte
as
(
Select EmployeeiD,(convert(varchar,(DATEDIFF(MINUTE,Min(DateAndTime),Max(DateAndTime))/60)) + ':'
+ convert(varchar,(DATEDIFF(MINUTE,Min(DateAndTime),Max(DateAndTime))/60)))WorkedHoursAndMinutes,
Min(DateAndTime) As DateAndTime from EmployeeAttendance group by
EmployeeiD,convert(varchar,DateAndTime,101),convert(varchar,DateAndTime,101) having (
(DATEDIFF(MINUTE,Min(DateAndTime),Max(DateAndTime))/60) >= 12
or (DATEDIFF(MINUTE,Min(DateAndTime),Max(DateAndTime))) = 0 )
)
select * from Cte
where convert(varchar,Cte.DateAndTime,103) =
(select convert(varchar,@DateTime,103));