Return maximum list of list in Entity Framework C# -
i have these 2 classes :
public class result { public string plate { get; set; } public double confidence { get; set; } public int matches_template { get; set; } public int plate_index { get; set; } public string region { get; set; } public int region_confidence { get; set; } public long processing_time_ms { get; set; } public int requested_topn { get; set; } public list<coordinate> coordinates { get; set; } public list<candidate> candidates { get; set; } } public class candidate { public string plate { get; set; } public double confidence { get; set; } public int matches_template { get; set; } } i have query :
list<list<candidate>> lstcandidates = deserializedproduct.results.select(i=>i.candidates).tolist(); as can see have list of list<candidate>. every candidate has plate , confidence. need plate number maximum confidence in lstcandidates. how can value?
you can use selectmany orderby , use first methods.
var candidate = deserializedproduct .results .selectmany(i=>i.candidates) // flatten collection .orderbydescending(p => p.confidence) // order descending on confidence property .first(); // take max
Comments
Post a Comment