I am getting db has been disposed error when trying to display IEnumerable items to partial view. Please check the error screen shot attached at bottom. If you have any question then plz ask. Thanks in advance.
View:
@model IEnumerable<Blexz.Models.Product>
@foreach(var item in Model)
{
<span>@item.Title</span>
}
Controller:
[ChildActionOnly]
[Authorize]
public PartialViewResult _UserBookmark(string id)
{
using (BlexzWebDbEntities db = new BlexzWebDbEntities())
{
int userId = db.Users.Where(x => x.Email == id).FirstOrDefault().UserId;
IEnumerable<int> ProductIds = db.Bookmarks.Where(x => x.UserId == userId).Select(x => x.ProductId);
IEnumerable<Product> ListOfProducts = db.Products.Where(x => ProductIds.Contains(x.ProductId));
return PartialView("_UserBookmark",ListOfProducts);
}
}