我在LINQ语句中使用以下分组。
我已经弄清楚如何从'notes'表中获取最大日期,但是我很难找到一种有效的方法来查找同一记录的'NoteText'属性(在两个地方用????突出显示)
group new { t1, notes } by new
{
t1.Opportunity_Title
} into g
let latestNoteDate = g.Max(uh => uh.notes.Date)
let latestNote = g.Max(uh => uh.notes.NoteText) < needs to be latest note for record above ^
select new PipelineViewModel
{
LastNoteDate = latestNoteDate,
LastNote = latestNote, ????
}).Take(howMany);
答案 0 :(得分:2)
也许是这样:
let latestNote = latestNoteDate == null ? null :
g.First(x => x.notes.Date == latestNoteDate).NoteText