1、单一产品情况下使用:
public ActionResult GetStockList(){ var item = _db.Stocks.ToList().Select(s =>s.Product.CodePro); return Json(item, JsonRequestBehavior.AllowGet);}
2、多组返回值的情况下:
public ActionResult AutocompleteSuggestions(string term){ var suggestions = db.Students.Select(s => new { label = s.LastName+"|"+s.FirstMidName, value = s.StudentID}).Where(b=>b.label.ToLower().StartsWith(term.ToLower())); return Json(suggestions, JsonRequestBehavior.AllowGet);}