Requete linq to sql faire un genre de distinct
bonjour suis confronté a un probleme au faite pour commencer jai une table annonce et commentaire lid de annonce migre dans commentaire maintenant jai la page daffichage des annonce et leurs caracteristique le probleme est que une annonce est dupliqué autant de fois quelle possede de commentaire cest ta dire si jai une annonce : titre blabla description blala avec 4 commentaires donc le titre blabla et description blabla serons repeté 3 fois voici ma requette
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
var query = from a in dc.Region
join b in dc.Annonce
on a.IdReg equals b.idRegion
join z in dc.Annonceur on b.idAnnonceur equals z.IdAnnonceur
join x in dc.Ttypeannonce
on b.idtypeannonce equals x.idtypeannonce
join e in dc.Categorie on b.idCategorie equals e.IdCat join f
in dc.Commentaire on b.IdAnn equals f.IdAnn
where (b.IdAnn == id )
select new Ann_Region_Cate { Region = a, Annonce = b, Annonceur = z, Ttypeannonce = x, Categorie = e,Commentaire=f }; |
voici la vue
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
@foreach (var item in Model)
{
<span style="border:2px solid red;position:relative;bottom:200px;">
<table width="602" border="0" cellspacing="5" cellpadding="0" class="tabs" id="addCommentContainer" style="border:2px solid red; bottom:185px;">
<tr>
<th width="105" scope="col"><div align="left"><strong>Nom : </strong></div></th>
<th width="476" scope="col"><div align="left" class="Style6"> @Html.DisplayFor(modelItem => item.Commentaire.NomComment) </div></th>
</tr>
<tr>
<td><div align="left"><strong>Email : </strong></div></td>
<td width="476"><div align="left" class="Style6"> @Html.DisplayFor(modelItem => item.Commentaire.EmailComment) </div></td>
</tr>
<tr>
<td><div align="left"><strong style="white-space:nowrap">Commentaire : </strong></div> <img src="~/Images/usa.png" class="im" width="70" height="45"/></td>
<td width="476" rowspan="2" valign="top"><div align="left" class="Style6" id="comme">@Html.DisplayFor(modelItem => item.Commentaire.LibelleCommentaire) <pre>
</td>
</tr>
</table>
</span>
} |
cette vue se trouve dans la page detail qui est afficher en fonction de lid dune annonce cest a dire lors du clique sur le lien
NB: je vois pas pourquoi lannonce est dupliqué autant de fois quelle est commentée
sos svp