c# - Linq query with grouping to fetch youngest date -
my case, see below image: i designed query , added grouping grouping not reduce records youngest contractenddate. appears have no effect on result. public iqueryable<soonobsoletecontractsviewmodel> get() { var countries = unitofwork.getall<country>(); var companies = unitofwork.getall<company>(); var contracts = unitofwork.getall<contract>(); var query = country in countries join company in companies on country.id equals company.countryid join contract in contracts on company.id equals contract.companyid select new soonobsoletecontractsviewmodel { countryname = contry.name, companyname = company.name, companyid = company.companyid contractbegindate = contract.begin, contractenddate = contract.end, contractid = contract.id }; query.groupby(c => c.companyid, (key, e) => e.order...