linq中的多条件查询:
from s in data4
join d1 in data_co on new {s.FORECASTTIME,s.REGIONCODE}
equals new {d1.MONIDATE ,d1.REGIONCODE}
但这只能实现一个join关联,当有多个join时候会报错。
修改如下 :join d1 in data_co on s.FORECASTTIME equals d1.MONIDATE
where s.REGIONCODE==d1.REGIONCODE
可实现多个join多条件的关联
var data7 = (
from s in data4join d1 in data_co on s.FORECASTTIME equals d1.MONIDATE
where s.REGIONCODE==d1.REGIONCODE
join d2 in data_NO2 on s.FORECASTTIME equals d2.MONIDATE
where s.REGIONCODE == d2.REGIONCODE
join d3 in data_SO2 on s.FORECASTTIME equals d3.MONIDATE
where s.REGIONCODE == d3.REGIONCODE
join d4 in data_O3 on s.FORECASTTIME equals d4.MONIDATE
where s.REGIONCODE == d4.REGIONCODE
join d5 in data_O38H on s.FORECASTTIME equals d5.MONIDATE
where s.REGIONCODE == d5.REGIONCODE
join d6 in data_PM10 on s.FORECASTTIME equals d6.MONIDATE
where s.REGIONCODE == d6.REGIONCODE
join d7 in data_PM25 on s.FORECASTTIME equals d7.MONIDATE
where s.REGIONCODE == d7.REGIONCODE
select new
{
REGIONCODE = s.REGIONCODE,
FORECASTTIME = s.FORECASTTIME,
REGIONNAME = s.REGIONNAME,
CO = (decimal)d1.CO,
NO2 = (short)d2.NO2,
SO2 = (short)d3.SO2,
O3 = (short)d4.O3,
O38H = (short)d5.O38H,
PM10 = (short)d6.PM10,
PM25 = (short)d7.PM25
}).OrderBy(a => a.REGIONCODE);