1
I have a class called Attending. in it I have the following attributes:
public class Atendimento
{
public Guid AtendimentoId { get; set; }
public Guid? ResponsavelPorAtender { get; set; }
public Guid? AdmQueAutorizou { get; set; }
public virtual Usuario Usuario { get; set; }
public Guid IdUsuario { get; set; }
}
the attribute public Guid? ResponsavelPorAtender
and public Guid? AdmQueAutorizou
are the users tbm, in the same way as the public Guid IdUsuario
when I make a query, which searches all calls, as I do to assign the name of the user, to for example:public Guid? ResponsavelPorAtender
as regards the public Guid IdUsuario
I just use the include.
public IEnumerable<Atendimento> ObterTodos()
{
return Db.AtendimentosDb.Include("Usuario");
}
and show in my Index Asssim:
<table
<thead style="width:100%">
<tr>
<th>
Aberto Por:
</th>
<th>
Fechado Por:
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Usuario.Nome)
</td>
<td>
@Html.DisplayFor(modelItem => item.ResponsavelPorAtender )
</td>
</tr>
}
</tbody>
</table>
Redeemable by meeting is the ID of the user you have anticipated. how do I search for each item on that list?
User class:
public class Usuario
{
public Guid UsuarioId { get; set; }
public string Nome { get; set; }
public string Cpf { get; set; }
public string Senha { get; set; }
public TipoDeUsuario TipoDeUsuario { get; set; }
}
How’s your relationship? Could you add your class
Usuario
?– Renan Carlos
I edited, and I put the user class
– Rafael Passos