public IActionResult Index() { var listFormations = _repository.GetFormations(4); var vm = new List <DetailFormationViewModel>(); foreach (var f in listFormations) { vm.Add( new DetailFormationViewModel { Formation = f, NoteMoyenne = f.Avis.Select(a => a.Note) .DefaultIfEmpty(0).Average() }); } return(View(vm)); }