Object.SousObject dans cshtml
Bonjour,
Je ne sais pas si l'intitulé du problème correspond bien :mrgreen:
J'ai deux object, Question et Proposition telle que :
Code:
1 2 3 4 5 6 7 8
|
public class Question
{
public int Id { get; set; }
[Display(Name = "Énoncé")]
public string Enonce { get; set; }
public virtual List<Proposition> LesPropositions { get; set; }
} |
Code:
1 2 3 4 5 6 7
|
public class Proposition
{
public int Id { get; set; }
public string Libelle { get; set; }
public bool Reponse { get; set; }
} |
Je souhaite afficher dans ma vue la liste des questions avec, pour chaque question, la liste de ces propositions.
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 25
|
<table>
<tr>
<th>Id</th>
<th>Enonce</th>
<th>Propositions</th>
<th>Modifier</th>
</tr>
@foreach (var question in Model)
{
<tr>
<td>@question.Id</td>
<td>@question.Enonce</td>
<td>
@foreach (var proposition in question.LesPropositions)
{
<li>@proposition.Libelle</li>
}
</td>
<td>@Html.ActionLink("Modifier " + question.Id, "UpdateQuestion", new { id = question.Id })</td>
</tr>
}
</table> |
J'ai une erreur quand je fait "@foreach (var proposition in question.LesPropositions)"
Citation:
The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.
J'ai cherché sur le net mais je n'arrive pas à comprendre les réponses...
Pouvez-vous m'aider?
Merci d'avance.