方法1
var d = Context.CodeTree
.Select(o => new { o.Name, o.Value });
方法2
var result = from o in Context.CodeTree
.Select
(
o => new { o.Name, o.Value }
)
select o;
方法3
IEnumerable
db.Student.Where(c => c.StudentCategoryID == CategoryID)
.AsEnumerable().Select(c => new SelectListItem()
{
Text=c.Name,
Value=c.StudentID.ToString()
});
SelectList StudentID = new SelectList(Studentitems, "Value", "Text");
方法1
return Content(JsonConvert.SerializeObject(result), "application/json");
方法2
ViewBag.result = JsonConvert.SerializeObject(result);
方法3
return Json(StudentID, JsonRequestBehavior.AllowGet);
【View】
var q = '@Html.Raw(ViewBag.result)'
沒有留言:
張貼留言