在显示所有优惠的“索引”页面中,我正在尝试获取加入每个特定优惠的所有客户的计数,我在下面的视图中使用:
加入客户:@ item.OfferCustomerTBLs.Count()
但它给我的错误: 值不能为空。
那么,请告诉我如何使用客户的联接对象的数量,并且当null显示什么时?
答案 0 :(得分:0)
问题出在Controller中,我必须将连接的对象包括为:
public ActionResult Index()
{
return View(offersTBLs.Include(y=>y.OfferCustomerTBLs).ToList());
}
感谢所有试图帮助的人,谢谢Mairaj Ahmad