Hi,
I have in the database table Deal having DealId and table Product having ProductId. I have table ProductDeal having ProductId and DealId for the many to many relation between the tables product and deal. Now in the models I have
[Table("Deal")]
public class Deal
{
[Key]
public int DealId { get; set; }
public string Title { get; set; }
public Dealproduct[] DealProducts { get; set; }
}
public class Dealproduct
{
public int ProductId { get; set; }
}
[Table("Product")]
public class Product
{
[Key]
public int ProductID { get; set; }
public string ProductTitle { get; set; }
}Now in the Context I have
public DbSet<Product> Prioducts { get; set; }
public DbSet<Deal> Deals { get; set; }
public DbSet<ProductDeal> ProductDeals { get; set; }when I'm loading the deals:
var deals = new List<Deal>();
try
{
using (var context = new myContext(connString))
{
var query = context.Deals;
deals = query.ToList();
}
}
catch (Exception exc)
{}but in this way I'm not getting the list of products for a deal because it is saved in the productDeal table. How do I load the list of products for a deal? I need only list of Ids, not complete list of products.
Thanks