码迷,mamicode.com
首页 > Web开发 > 详细

Entity Framework json 序列化含有导航属性的实体

时间:2016-08-07 20:06:50      阅读:511      评论:0      收藏:0      [点我收藏+]

标签:

        public ActionResult User_Query2()
        {
            //通过用户手机号查寻 该用户的所有邮包记录
            string User_Tel1 = Request.Form["User_Tel"];
            if (User_Tel1 == null)
            {
                return HttpNotFound();
            }
            List<Parcel_info> parcel_info_List = new List<Parcel_info>();
            Parcel_info d = new Parcel_info();

            var parcel_info = db.Parcel_info;
            var parcel_info_All = parcel_info.Where(o => o.ReceiveTel == User_Tel1);
            foreach (var o in parcel_info_All)
            {
                d.ID =int.Parse ( o.ID.ToString());
                d.ParcelNo = o.ParcelNo.ToString();
                d.TargetAddress = o.TargetAddress.ToString();
                d.SendTel = o.SendTel.ToString();
                d.ReceiveTel = o.ReceiveTel.ToString();
            }
            parcel_info_List.Add(d);
            if (parcel_info_List == null)
            {
                return HttpNotFound();
            }
            var jsonResult = new { total = parcel_info_List.Count, rows = parcel_info_List };
            return Json(jsonResult, JsonRequestBehavior.AllowGet);
        }

Entity Framework json 序列化含有导航属性的实体

标签:

原文地址:http://www.cnblogs.com/dingfangbo/p/5746803.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!