日期:2014-05-20  浏览次数:20826 次

这条sql语句换成linq如何写??
有如下的表结构: 
SQL code 
insert into DWSFI(SurveyYear,WaterSouceCode,DesignIntake) values('2009-10-08 00:00:00.000','S01',32) 
insert into DWSFI(SurveyYear,WaterSouceCode,DesignIntake) values('2009-01-09 00:00:00.000','S01',367) 
insert into DWSFI(SurveyYear,WaterSouceCode,DesignIntake) values('2009-10-09 00:00:00.000','R01',43) 
insert into DWSFI(SurveyYear,WaterSouceCode,DesignIntake) values('2009-01-07 00:00:00.000','R01',8) 

由于同一个WaterSouceCode有多条不同时间的记录 我现在只提取时间最大的记录,可采用如下的sql语句: 
SQL code
select * from DWSFI t
where SurveyYear = (select max(SurveyYear) from DWSFI where WaterSouceCode=t.WaterSouceCode)



但是如果换成linq要怎么写呢??

------解决方案--------------------
晕!!老是掉符号。。。
var tmpResult = (from c in DWSFI order by c.SurveyYear descending select c).First();