Make JOIN with 2 classes [closed]

-2

How to make a JOIN for the Customer Code to appear in the Name?

    
asked by anonymous 26.09.2015 / 01:45

2 answers

2

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
    
26.09.2015 / 23:06
0

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 ...

    
26.09.2015 / 01:58