public ActionResult Goods_Index() { ViewBag.goods = GoodsBll.GetAll().OrderBy(u => u.Goods_ID).Take(4); ViewBag.type = GoodsTypeBll.GetAll().Where(u => u.Type_Name.Contains("手机")).FirstOrDefault(); ViewBag.type1 = GoodsTypeBll.GetAll().Where(u => u.Type_Name.Contains("平板")).FirstOrDefault(); ViewBag.type2 = GoodsTypeBll.GetAll().Where(u => u.Type_Name.Contains("笔记本")).FirstOrDefault(); int id = ViewBag.type.Type_ID; int id1 = ViewBag.type1.Type_ID; int id2 = ViewBag.type2.Type_ID; ViewBag.phone = GoodsBll.GetAll().OrderByDescending(u => u.Goods_ID).Where(u => u.Type_ID == id).Take(5); ViewBag.phone1 = GoodsBll.GetAll().OrderByDescending(u => u.Goods_ID).Where(u => u.Type_ID == id).Take(3); ViewBag.tablet = GoodsBll.GetAll().OrderByDescending(u => u.Goods_ID).Where(u => u.Type_ID == id1).Take(3); ViewBag.laptop = GoodsBll.GetAll().OrderByDescending(u => u.Goods_ID).Where(u => u.Type_ID == id2).Take(3); return(View()); }