0
I currently have a view where a Table(Orders) is being loaded another table(Colors) I want each order to be a list of the color that has the same ID as the order.
My Tables:
public partial class Programa
{
    public int ID_Programa { get; set; }
    [System.ComponentModel.DataAnnotations.DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}")]
    public Nullable<System.DateTime> Data_Registo { get; set; }
    public string Num_Encomenda { get; set; }
 }
public partial class Programa_Cor
{
    public int ID_Programa { get; set; }       
    public string Cor { get; set; }
}
To use both models in a single view I created this class
public class EncomendaViewModel
{
    public IEnumerable<Programa> Programas { get; set; }
    public IEnumerable<Programa_Cor> ProgramasCor { get; set; }
}
What seemed to me logical was to associate a variable to the Id_programa field and compare it with the Id_programa of the Programas_cor table, but all colors are listed on request and not only those that have the same ID.
My Controller:
var cor = color.Where(x => id.Contains(x.ID_Programa)).ToList()
        var tables = new EncomendaViewModel
        {
            Programas = embOpen.ToList(),
            ProgramasCor = cor.ToList(),
        };
I thank anyone who can help me!
---------------------Update-----------------------------
My View
<table class="table table-borderless table-sm " ;>
@foreach (var programa in Model.Programas)
{
    <tr style="border-top: 2px solid #cdd0d4;">
        <td style="width: 130px;">
            <b>Artigo: </b>@programa.Cod_Artigo
        </td>
        <td colspan="8">
            <b>Modelo: </b>@programa.Modelo
        </td>
    </tr>
    <tr>
        <td style="width: 200px;">
            <b>Nº Encomenda: </b>@programa.Num_Encomenda
        </td>
        <td style="width: 170px;">
            <b>Ref.Cliente: </b>@programa.Ref_Cliente)
        </td>          
    </tr>
    <tr>
        <td colspan="8">
            <table class="table table-bordered">
                @foreach (var programa_Cor in Model.ProgramasCor)
                {
                    <tr>
                        <td style="width: 150px;">
                            @programa_Cor.Cor)
                        </td>                        
                    </tr>
                }
            </table>
        </td>
    </tr>
}
At this time I have the colors that are loaded are only one id for testing as it carries same color in all Orders

Your modeling is a little strange and the question was not specific enough. However: I believe you have a problem in your modeling. As far as I understood, the correct thing would be to change the table from "Programacor" to only "Cor" and in the table "Programa" to put a foreign key referencing the table "Cor". Therefore, each program would have a color.
– M. Bertolazo
The way you look it doesn’t make sense to have a class
Programa_Cor, only one propertyCorin the program class– Leandro Angelo
I’m going to put my view up to better understand my project
– Miguel