linq源码改错!!!
这个对应我的另一个帖子中提到的较复杂的功能的代码;用的自己的思路写的,第一次碰C#,劳烦各位版主原谅我的各种低级错误阿
var reportQuery = from a in examReportTable.AsEnumerable()
join b in rvuTable.AsEnumerable()
on new{exam=a.Field<string>("exam"), examtype=a.Field<string>("examtype")} equals new{rvuName=b.Field<string>("rvuName"), rvuType=b.Field<string>("rvuType")}
group b by new{ reportDoc=a.Field<string>("reportDoc"),examtype=a.Field<string>("examtype") } into c
select new
{
DocName = c.Field<string>("reportDoc"),
examType = c.Field<string>("type"),
reportDocRvu = c.Field<double>.Sum(o=>o.reportRvu),
reportDocNum = c.Field<double>.count(o=>o.reportRvu)
};
var auditQuery = from aa in examAuditTable.AsEnumerable()
join bb in rvuTable.AsEnumerable()
on new{exam=aa.Field<string>("exam"),examtype=aa.Field<string>("examtype")} equals new{rvuName=bb.Field<string>("rvuName"),rvuType=bb.Field<string>("rvuType")}
group bb by new{aa.auditDoc,aa.examtype} into cc
select new
{
DocName = cc.reportDoc,
examType = cc.type,
auditDocRvu = cc.Sum(o=>o.auditRvu),
auditDocNum = cc.Count(o=>o.auditRvu)
};
private DataTable workloadTable;
workloadTable.Columns.Add("docName",typeof(string));
workloadTable.Columns.Add("type",typeof(string));
workloadTable.Columns.Add("reportDocRvu", typeof(double));
workloadTable.Columns.Add ("reportDocNum",typeof(double));
workloadTable.Columns.Add ("auditDocRvu",typeof(double));
workloadTable.Columns.Add ("auditDocNum",typeof(double));
foreach (var q in reportQuery )
{
workloadTable.Rows.Add(q.DocName, q.examType,q.reportDocRvu,q.reportDocNum,0,0);
}
foreach (var q in auditQuery)
{
workloadTable.Rows.Add(q.DocName, q.examType, 0,0,q.auditDocRvu, q.auditDocNum);
}
var rvuQuery = from a in workloadTable.AsEnumerable()
group a by new {docName=a.Field<string>("docName"),type=a.Field<string>("type") }into g