【发布时间】:2023-03-11 23:40:01
【问题描述】:
我的网络服务将 DateTime 返回到 jQuery 调用。服务以这种格式返回数据:
/Date(1486308595040)/
我从数据库表中获取多个数据,我看过很多关于此的文章,他们回答了这个:
var d = new Date();
d.setTime(1245398693390);
document.write(d);
但是我从那个答案中有 1000 条或更多记录,我必须获取每一行并将其转换为不适合的 json 友好数据。
我的代码:
var history = db.v_recharge_payment_History.Where(x => x.RCV_UID == loginQuery.ID).OrderByDescending(x => x.RCV_ID).Take(10).ToArray();
dictionary.Add("result", 200);
dictionary.Add("data", history);
return Json(dictionary, JsonRequestBehavior.AllowGet);
如何在不迭代每一行的情况下将其转换为 JavaScript 友好的日期?
【问题讨论】:
-
@quasoft,这个答案说你必须转换每行的每个日期时间列,如果我有 10,000 条或更多记录,这是不可能的,谢谢你的回答
-
1000 行是什么意思?您的
.Take(10)仅返回 10 行。
标签: c# jquery asp.net json asp.net-mvc