Select List item with max value using LINQ query

前端 未结 3 1094
無奈伤痛
無奈伤痛 2021-01-26 12:01

I have List loadRecords where T type defines as follow

public class TransformerLoadRecord
{

    public double TotalLoadKva { get; set; }
    public double Total         


        
3条回答
  •  遥遥无期
    2021-01-26 12:34

    The following should work:

    var mxKVALoad = loadRecords
                    .Where(l => l.totalLoadKva == loadRecords.Max(l => l.TotalLoadKva));
    

    Alternatively, you can use MaxBy from the MoreLINQ library

提交回复
热议问题