我正在尝试创建一个属性“Level”,如果记录CompletedDate是整个结果集中的最大/最大值,则将其设置为0,否则将其设置为1.我需要知道它的“级别”是什么出于输出目的,所以我可以正确渲染嵌套的div。任何想法都会非常感激。
From g In pciData.AsEnumerable() _
Order By (g.SmartForm.CompletedDate) Descending _
Select _
Name = IIf(g.SmartForm.FormName Is Nothing, "", g.SmartForm.FormName.ToString()), _
Level = IIf( _
iif(Date.Parse(g.SmartForm.CompletedDate) = "GET MAX DATE OF RESULT SET HERE", 0, 1)
ANSWER
Level = IIf(Date.Parse(g.SmartForm.CompletedDate) = _
Date.Parse(pciData.Max(Function(m) m.SmartForm.CompletedDate)), 0, 1)
答案 0 :(得分:2)
尝试这样的事情:
(未经测试的手绘类型代码..可能包含拼写错误)
From g In pciData.AsEnumerable() _
Let MaxDate = g.max(function(f) f.CompletedDate) _
Order By (g.SmartForm.CompletedDate) Descending _
Select _
Name = IIf(g.SmartForm.FormName Is Nothing, "", g.SmartForm.FormName.ToString()), _
Level = IIf( _
iif(Date.Parse(g.SmartForm.CompletedDate) > MaxDate, 0, 1)