I have two tables product and Images. They have a one-to-many relationship. I want to display product name and all its related images in the view, I am using repository pattern. I am new to MVC and Linq please help. Thanks in advance.
Here is my code....
public partial class tbl_Product
{
public int pro_id { get; set; }
public string pro_name { get; set; }
public string pro_desc { get; set; }
public string pro_model { get; set; }
public string pro_dimensions { get; set; }
public Nullable<int> pro_UnitsInStock { get; set; }
public Nullable<double> pro_price { get; set; }
public Nullable<double> pro_oldprice { get; set; }
public virtual ICollection<tbl_Images> tbl_Images { get; set; }
}
ProductRepository class:
public ProductDetail GetProductByID(int id)
{
var product = this.storeDB.tbl_Product.Where(x => x.pro_id == id).FirstOrDefault();
return product;
}