var result = from m in userPrefers.GroupBy(t => new { t.Pet_Preferential.Merchant.MerchantId, t.Pet_Preferential.Merchant.MerchantName }) select new { MerchantId = m.Key.MerchantId, MerchantName = m.Key.MerchantName, Preferential = from u in m orderby u.Pet_Preferential.MinAmount descending select new { Id = u.Id, PreferentialId = u.Pet_Preferential.Id, Context = u.Pet_Preferential.Context, isDiscount = u.Pet_Preferential.isDiscount, MinAmount = u.Pet_Preferential.MinAmount, Preferential = u.Pet_Preferential.Preferential, UseCondition = u.Pet_Preferential.UseCondition, ProSales = u.Pet_Preferential.ProSales, PreferentialNum = u.Pet_Preferential.PreferentialNum, } };