我在列表中有以下项目:
Date Amount AnId AnotherId MainDate
2013/01/10 1000 1 5 2013/01/12
2013/01/11 2000 2 5 2013/01/12
2013/01/15 4000 1 5 2013/01/12
我想使用 linq 返回以下内容:
Date Amount AnId AnotherId MainDate
2013/01/11 2000 2 5 2013/01/12
2013/01/15 4000 1 5 2013/01/12
即对于特定的,我只想要在和MainDate之间唯一的最新项目。因此,2013/01/10 上的项目被删除,因为有一个相同的项目,并且日期晚于项目日期......AnIdanotherIdMainDateAnIdAnotherId
我一直在尝试Group By MainDate和Then By AnId和OrderByDescendingAnotherId ,然后为每个组选择第一个项目,但对 linq 不太了解,所以我很挣扎......