错误在 qRow 上。如何用 linq 解决这个问题?我试图找到答案,但没有运气。
IEnumerable<DataColumn> iCols = (from i in Interlocks
join r in Results on i.InterlockID equals r.InterlockID
where r.StationType.Equals("RT") && r.LineID.Equals("1") && r.TestNo == 1 && r.StationID == 1
&& i.SerialNumber.Equals("C11205150001") && (r.DateTested >= DateTime.Now.AddMonths(-48) && r.DateTested <= DateTime.Now)
select new { i.SerialNumber,i.ModelNumber,r.DateTested,r.InterlockID,r.ResultID,r.ProgramDescription,r.TestStatus,r.CycleTime}).Distinct().Cast<DataColumn>();
interlock.Columns.Add("SerialNumber",Type.GetType("System.String"));
interlock.Columns.Add("ModelNumber", Type.GetType("System.String"));
interlock.Columns.Add("DateTested", Type.GetType("System.DateTime"));
interlock.Columns.Add("InterlockID", Type.GetType("System.Int32"));
interlock.Columns.Add("ResultID",Type.GetType("System.Int32"));
interlock.Columns.Add("ProgramDescription",Type.GetType("System.String"));
interlock.Columns.Add("CycleTime", Type.GetType("System.Int32"));
interlock.Columns.AddRange(iCols.ToArray());
interlock.AcceptChanges();
foreach (DataRow qRow in interlock.Rows)
{
var details = (from d in qRow
join rd in Results_Details on d.ResultID equals rd.ResultID
select new {d.DateTested,d.ResultID,rd.ResultNameID,rd.ResultValue}).Distinct();