if you have a external key in the database,
when you created the model you should have (inside your Category class) a virtual list to the Entries
then your code should be like that
public ActionResult Index([Bind(Prefix = "Id")] int categoryId)
{
var category = _db.Categories.Find(categoryId);
if (category != null)
{
return View(category.Entries);
}
return HttpNotFound();
}
otherwise you should filter your entries like that
public ActionResult Index([Bind(Prefix = "Id")] int categoryId)
{
var category = _db.Categories.Find(categoryId);
if (category != null)
{
var entries = _db.Entries.Where(e=>e.CategoryId == categoryId).ToList();
return View(entries);
}
return HttpNotFound();
}
i'm not sure if i understood correctly what you need, please tell me if i misunderstood
regards