当我尝试通过从数据库中选择来填充变量时,我收到以下错误:
“已经有一个与此命令关联的打开DataReader 必须先关闭。“
//Admin Venue Partial View
public ActionResult AdminVenuesTablePartialView()
{
VenueTownViewModel vt = new VenueTownViewModel();
List<VenueTownViewModel> model = new List<VenueTownViewModel>();
foreach (var venue in db.Venues)
{
vt.VenueID = venue.VenueID;
vt.VenueName = venue.VenueName;
vt.VenueTown = db.Towns.Find(venue.TownID).Town;
vt.VenueActive = venue.VenueActive;
model.Add(vt);
}
return PartialView("_AdminVenues", model.OrderBy(v => v.VenueName).ToList());
}