hmahdavi921
شنبه 22 اسفند 1394, 07:31 صبح
با سلام
من یک متد برای پاس دادن اطلاعات با فرمت json نوشتم.اما موقع پر کردن اطلاعات به آبجکت EF نمیتونه اطلاعات رو serialaize بکنه .
139568
مطابق عکس اطلاعات رو نمیتونه نشون بده .
[HttpPost]
public ActionResult GetCity(int idCountry)
{
TravelEnterAdminTemplate.Models.LG.MyJsonResult myresult = new Models.LG.MyJsonResult();
try
{
List<City> citylist = new List<City>();
var citystable = db.Cities.Where(p => p.CountryId == idCountry).ToList();
if (citystable != null)
{
foreach (var city in citystable)
{
myresult.obj = citystable;
}
myresult.Result = true;
}
else
{
myresult.Result = false;
myresult.message = "داده ای یافت نشد";
}
}
catch (Exception e)
{
errorlog.Error("DeleteShopping", "157", e.Source.ToString(), e.Message);
myresult.Result = false;
myresult.message = "خطا در بارگذاری اطلاعات";
}
return Json(myresult, JsonRequestBehavior.AllowGet);
}
من یک متد برای پاس دادن اطلاعات با فرمت json نوشتم.اما موقع پر کردن اطلاعات به آبجکت EF نمیتونه اطلاعات رو serialaize بکنه .
139568
مطابق عکس اطلاعات رو نمیتونه نشون بده .
[HttpPost]
public ActionResult GetCity(int idCountry)
{
TravelEnterAdminTemplate.Models.LG.MyJsonResult myresult = new Models.LG.MyJsonResult();
try
{
List<City> citylist = new List<City>();
var citystable = db.Cities.Where(p => p.CountryId == idCountry).ToList();
if (citystable != null)
{
foreach (var city in citystable)
{
myresult.obj = citystable;
}
myresult.Result = true;
}
else
{
myresult.Result = false;
myresult.message = "داده ای یافت نشد";
}
}
catch (Exception e)
{
errorlog.Error("DeleteShopping", "157", e.Source.ToString(), e.Message);
myresult.Result = false;
myresult.message = "خطا در بارگذاری اطلاعات";
}
return Json(myresult, JsonRequestBehavior.AllowGet);
}