public Task <IActionResult> FetchAllMatches() { //Recupero la lista dal layer var entities = BasicLayer.FetchAllMatches(); var associationIds = entities.Select(x => x.AssociationId).ToList(); var placeIds = entities.Select(x => x.PlaceId).ToList(); var associations = BasicLayer.FetchAssociationsByIds(associationIds); var places = BasicLayer.FetchPlacesByIds(placeIds); //Ritorno i contratti return(Reply(entities.As(x => ContractUtils.GenerateContract(x, associations.FirstOrDefault(p => p.Id == x.AssociationId), places.FirstOrDefault(p => p.Id == x.PlaceId))))); }