How to make a JOIN for the Customer Code to appear in the Name?
The Entity Framework means that you do not necessarily need to use JOIN
. If you have correctly mapped your entities, your Projeto
entity should look like this:
public class Projeto
{
public int ProjetoId { get; set; }
public int ClienteId { get; set; }
public String Nome { get; set; }
/* Aqui vão outras propriedades */
public virtual Cliente Cliente { get; set; }
}
This Cliente
navigation property already does the pro search for you. You do not need to do anything. Just type in View :
@projeto.Cliente.Nome
Assuming that your table containing the project data is named Project, and that it contains the client data, call Customer:
Select Projeto.Codigo, Cliente.Nome From Projeto
Inner Join Cliente on Projeto.idCliente = Cliente.idCliente
Where Projeto.Codigo = 1
I just sampled 2 fields, but you can put more ...