首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

sql to linq 转换

2013-10-06 
求一个sql to linq 转换select ID, Value, Time from TB where Time in (select max(Time) from TB where

求一个sql to linq 转换
select ID, Value, Time from TB where Time in (select max(Time) from TB where ID = TB.ID)
[解决办法]
首先,你应该把你的sql写成比较通用的 inner join 语句。
[解决办法]
var datasource=list.select(t=>{return new{t.ID,t.Value,T.Time};}).orderbydesc(o=>o.time).SingleOrDefault();
[解决办法]

引用:
select ID, Value, Time from TB where Time in (select max(Time) from TB where ID = TB.ID)

var query=TB.GroupBy(t=>t.ID).Select(g=>g.OrderBgyDescending(x=>x.Time).First());

[解决办法]
引用:
Quote: 引用:

Quote: 引用:

select ID, Value, Time from TB where Time in (select max(Time) from TB where ID = TB.ID)

var query=TB.GroupBy(t=>t.ID).Select(g=>g.OrderBgyDescending(x=>x.Time).First());

我写错了,应该是
select ID, Value, Time from TB t where Time in (select max(Time) from TB where ID = t.ID) 


真怀疑你懂不懂sql,还是就是一个传声筒。人家糖糖正确答案都给你了,你还“修正”。

热点排行