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

SQl用linq 如何用linq 的语法写出来呀
select Ent_ID,SDate,Count(distinct(callcode)) as CallIn_TRS_Suc
from HD201311 where SDate='20131104' and STime>='140000' and ETIME<='145959' and CallType=2 and Len(Called)>5 and TotalLen>0
group by Ent_id,SDate

select Ent_ID,SDate,Sum(TotalLen) as CallIn_Len
from HD201311 where SDate='20131104' and STime>='140000' and ETIME<='145959' and CallType=2 and Len(Called)>5 and TotalLen>0
group by Ent_id,SDate

SQl如何用linq 的语法写出来呀
Linq

------解决方案--------------------
var  query = from data in ds.Tables[0].AsEnumerable()
                         where data.Field<int>("CallType") == 2
                         group data by new { t1 = data.Field<int>("Ent_ID"), t2 = data.Field<string>("SDate") } into m
                         select new
                         {
                             
                             Ent_ID = m.Key.t1,
                             SDate = m.Key.t2,
                             CallAll = m.Select(x=>x.Field<string>("callcode")).Distintct().Count()   
                         };