public ModeleDeGamme GetOne(int id) { ModeleDeGamme dto = new ModeleDeGamme(); using (var db = new maderaEntities()) { var query = from a in db.MODELE_DE_GAMME where a.MODELE_GAMME_ID.Equals(id) select a; dto.Id = query.First().MODELE_GAMME_ID; dto.Nom = query.First().MODELE_GAMME_NOM; dto.Description = query.First().MODELE_GAMME_DESCRIPTION; dto.EstParDefaut = query.First().EST_PAR_DEFAUT; dto.NbPieces = query.First().MODELE_GAMME_NB_PIECES; dto.Surface = query.First().MODELE_GAMME_SURFACE; dto.TypeModeleGamme = typeModeleGammeRepository.GetOne(query.First().TYPE_MODELE_GAMME_ID); dto.Gamme = gammeRepository.GetOne(query.First().GAMME_ID); var image = from a in db.MODELE_GAMME_IMAGE where a.MODELE_GAMME_ID.Equals(dto.Id) select a; if (image.Count() != 0) { dto.Image = fichierRepository.GetOne(image.First().FICHIER_ID); } var queryFinitions = from a in db.LIER_FINITION where a.MODELE_GAMME_ID.Equals(id) select a; List <Finition> finitions = new List <Finition>(); foreach (var item in queryFinitions) { finitions.Add(finitionRepository.getOne(item.FINITION_ID)); } dto.Finitions = finitions; dto.Modules = moduleRepository.GetCompositionByIdModeleGamme(id); } return(dto); }