您能帮忙将此查询从sql转换为linq吗

您能帮忙将此查询从sql转换为linq吗

本文介绍了您能帮忙将此查询从sql转换为linq吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 选择 LogYear,LogMonth,LogDay,UserId,DateDiff(mi,MIN(cast(cast(cast(LogYear   varchar ( 4 ))+ ' /' + cast(LogMonth  as   varchar ( 2 ))+ ' /' + cast(logday  as   varchar ( 2 ))+ ' ' + Cast(LogHour  as   varchar ( 2 ))+ ' :' + cast(LogMinute  as   varchar ( 2 )) as   datetime ))),MAX(cast(cast(cast(LogYear  as   varchar ( 4 ))+ ' /' + cast(LogMonth  as   varchar ( 2 ))+ ' /' + cast(logday  as   varchar ( 2 ))+ ' ' + Cast(LogHour  as   varchar ( 2 ))+ ' :' + cast(LogMinute   varchar ( 2 )) as   datetime )))))来自日志
 通过 LogYear,LogMonth,LogDay,UserId
订单 通过 UserId 
解决方案


 昏暗 q =来自日志 In 日志_
        选择 log.LogYear,log.LogMonth,log.LogDay,log.UserId,LogTimeStamp = 新建 DateTime( log.LogYear,log.LogMonth,log.LogDay,log.LogHour,log.LogMinute, 0 )_
        按用户编号排序

 Dim 持续时间= q.Max( Function (l)l.LogTimeStamp)-q.Min(函数(l)l.LogTimeStamp)


select LogYear, LogMonth, LogDay,UserId, DateDiff(mi,MIN(cast(cast(LogYear as varchar(4)) + '/' + cast(LogMonth as varchar(2))+ '/' + cast(logday as varchar(2)) + ' ' + Cast(LogHour as varchar(2)) + ':' + cast(LogMinute as varchar(2)) as datetime)),MAX(cast(cast(LogYear as varchar(4)) + '/' + cast(LogMonth as varchar(2))+ '/' + cast(logday as varchar(2)) + ' ' + Cast(LogHour as varchar(2)) + ':' + cast(LogMinute as varchar(2)) as datetime)))  from logs
Group By LogYear, LogMonth, LogDay, UserId
Order by UserId
解决方案


这篇关于您能帮忙将此查询从sql转换为linq吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 10:08