我有一个快速的问题。我可以在 select 语句中执行所有这些逻辑吗?
var entries = atisDAO.GetPME(xl, null);
response.Data.Detectors = new List<DetectorDetails>(entries.Select(pme => new DetectorDetails {ID = pme.PlaceNum.ToString()}));
if(response.Data.Detectors.Any())
{
response.Data.Detectors.ForEach(d =>{
int id;
if(int.TryParse(d.ID, out id))
{
var summaries = atisDAO.GetSummaryEntries(id);
if (summaries.Any())
{
var count = summaries.Sum(summary => summary.TODCount + summary.BFICount + summary.ViolationCount);
var detectionDate = summaries.Max(summary => summary.ReadDate);
d.Count = count.ToString();
d.DetectionTime = new DateTimeZone {
ReadDate = detectionDate.ToString(DATE_FORMAT)
, ReadTime = detectionDate.ToString(TIME_FORMAT)
};
}
}
});
}
做一个选择感觉不对,然后循环遍历列表并修改我刚刚选择的项目。我可以在 select 语句中执行所有这些操作吗?
感谢您的任何提示。
干杯,
~ck 在圣地亚哥