1

我在我的 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);
4

1 回答 1

2

或许是这样的:

let latestNote = latestNoteDate == null ? null : 
                 g.First(x => x.notes.Date == latestNoteDate).NoteText
于 2012-05-10T15:52:49.930 回答