I have a database that has two tables: Order and Product. This database is exposed via an Entity Data Model and LINQ-to-Entities.
I have a product ID and I want to get all of the Order objects that reference the Product. I would like to learn how to do this with LINQ. I know I can query the products
int productID = GetProductID();
using (DatabaseContext database = new DatabaseContext())
{
var products = from product in database.Products
where product.ProductID = productID
select product;
}
I know this LINQ query get me all of the products with a specific product ID. However, I want the Order objects. I was trying to figure out to do a Join and get the just the Order objects. I do not care about the products as I have the product id. Is there a way to do this?
Thank you!
1 Answer