I've a class
I'm writing a method FindFirst which queries a collection of DeclInfo to find an earliest instance:Code:Class DeclInfo { public int Year {get; set;} public int Quarter {get; set;} public int CorrectionNumber {get; set;} // ... } // class DeclInfo
Find earliest year, then find earliest quarter and then find the latest (max) correction number.
Now I have the following:
I don't like what I see very much and therefore - a question - is there a way to make it simpler?Code:int Criteria = allDecls.Min(d => d.Year); allDecls = allDecls.Where(d => d.Year == Criteria).ToList(); Criteria = allDecls.Min(d => d.Quarter); allDecls = allDecls.Where(d => d.Quarter == Criteria).ToList(); Criteria = allDecls.Max(d => d.CorrectionNumber); di = allDecls.First(d => d.CorrectionNumber == Criteria);


Reply With Quote
