How can I load multiple table data in the Entity Framework? By RAW Query
I get normal, but by the Entity Framework I'm not getting to the point.
What do I need to select the last entry that contains a specific product (I will pass the ID) ordered by the descending DataCadastro (identify which is the last one) and together select the PRODUCT object that I passed the ID?
Note:
I've removed annotations and mapping to decrease the size of the post!
I access the entry through my:
contexto.Entrada.Lista().Where(...).OrderByDescending(m => m.DataCadastro).FirstOrDefault();
Classes:
class Entrada {
public int Id { get; set; }
public DateTime DataCadastro { get; set; }
public virtual ICollection<ItemEntrada> Items;
}
class Produto {
public int Id { get; set; }
public string Nome { get; set; }
}
class ItemEntrada {
public int Id { get; set; }
public int EntradaId { get; set; }
public int ProdutoId { get; set; }
public virtual Produto Produto { get; set; };
public virtual Entrada Entrada { get; set; };
}