1
I am working with MVC4 and Restsharp for data access via API Rest,
My return is an object of the type Object
but I cannot recover a specific property of this object.
How can I access the property?
Follow view code in which I need to recover the property.
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.descricao)
</td>
<td>
@{
var responsavel = item.responsavel.GetType().GetProperty("nome").GetValue(item.responsavel, null);
@Html.DisplayFor(modelItem => item.responsavel);
}
</td>
<td>
@Html.ActionLink("Editar", "Edit", new { id=item.id }) |
@Html.ActionLink("Detalhes", "Details", new { id=item.id }) |
@Html.ActionLink("Deletar", "Delete", new { id=item.id })
</td>
</tr>
You can show the code you currently have to illustrate the problem?
– dcastro
You have already tried the cast for the desired object type?
– Carlos Martins
I need this property to display in the view. I couldn’t do the cast at all.
– Mateus Rama
Why not change the return type of the action to the object type?
– dcastro
Forgive my ignorance, but I could be more clear?
– Mateus Rama
I explained it wrong. Which is the type of the variable
Model
?– dcastro