请如何解决此错误
序列化对象时检测到循环引用 在
public JsonResult SelectStates(int id)
{
IEnumerable<BPP.CCSP.Admin.Web.BPPCCSPAdminStatesService.STATES> states = _statesService.GetStates().Where(stat => stat.COUNTRY_ID == id);
return Json(states);
}
STATES定义:
public int STATE_ID { get; set; }
public Nullable<int> COUNTRY_ID { internal get; set; }
public string STATE_NAME { get; set; }
答案 0 :(得分:0)
解决了。我用过这段代码
public JsonResult GetStates(string id)
{
List<SelectListItem> states = new List<SelectListItem>();
var stateList = this.Getstate(Convert.ToInt32(id));
var stateData = stateList.Select(m => new SelectListItem()
{
Text = m.STATE_NAME,
Value = m.STATE_ID.ToString(),
});
return Json(stateData, JsonRequestBehavior.AllowGet);
}
由于