Hi, I have many different relationships as shown below.
public class order { public int id { get; set; } public virtual ICollection<OrderProducts> Products { get; set; } } public class product { public int id { get; set; } public virtual ICollection<OrderProducts> Orders { get; set; } } public class OrderProducts { public int OrderId { get; set; } public virtual Order Order{ get; set; } public int ProductIdId { get; set; } public virtual Product Product { get; set; } }
I would like to include (load) all products in my orders, but using the same approach as shown with the client, my product list is populated with OrderProducts, not Product-objects
public IEnumerable<Order> GetAll() { return dataContext.Orders .Include(order => order.Customer)
I tried things like witout any luck
.Include(order => order.Products.Where(op => op.OrderId == order.Id).Select(p => p.Product))
So if someone can help me here. You can also share any good resources on how to build more advanced lambdas since I am not familiar with this yet.
source share