Try with this model using Entity Framework Code First...
public class Product{
public int productid {get;set;}
public int catID {get;set;}
public string productname {get;set;}
public string description {get;set;}
[ForeignKey("catID")]
public virtual Category ProductCategory
[JsonIgnore]
public virtual ICollection<ProductPhoto> Photos
}
public class ProductPhoto{
public int ProductPhotoID {get;set;}
public int Productid {get;set;}
public string Photopath {get;set;}
[ForeignKey("Productid")]
public virtual Product ProductOwner
}
public class Category{
public int CatID {get;set;}
public string CatName {get;set;}
[JsonIgnore]
public virtual ICollection<Product> Products
}
Then set your DbContext using
DbSet<Category> Categories, DbSet<Product> Products, DbSet<ProductPhoto> ProductPhotos. If you are not using JSON serialization you can easily ignore [JsonIgnore] attribute.
Use this query to retieve images from Product based on category. I am retrieving the images of the first product only.
var v = dbContext.Products.Where(p=>p.catID == suppliedCatgoryId).First();
var images = v.Photos
Let me know if this helps.