0
我有一個.net核心MVC項目,其中我使用pagination定義PR。微軟文檔。大紀元/ Unix時間戳(毫秒),以日期時間在Razor視圖
由於這是這種情況,並且由於我的數據庫時間戳在Epoch中,所以我需要將時間戳轉換爲日期時間對象,因爲它用於我的Razor視圖中的表格。該表創建如下:
@model PaginatedList<MSPFrontend.Tripmetadata>
<div class="table-responsive">
<table class="table table-bordered table-condensed table-hover table-striped">
<thead>
<tr>
<th>Trip Id</th>
<th>Start Time</th>
<th>End Time</th>
<th>Duration</th>
<th>Avg Speed</th>
<th>Distance</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr class="trip" data-id="@item.Tripid" data-url="@Url.Action("TripMapping", "Trip")">
<td>@item.Tripid</td>
<td>@item.Starttimestamp</td>
<td>@item.Endtimestamp</td>
<td>@item.Duration</td>
<td>@item.AvgSpeed knots</td>
<td>@item.Distance km</td>
</tr>
}
</tbody>
</table>
</div>
我的模型如下所示:
public partial class Tripmetadata
{
public Tripmetadata()
{
}
[Key]
public int Tripid { get; set; }
[Display(Name = "Start Timestamp")]
public long? Starttimestamp { get; set; }
[Display(Name = "End Timestamp")]
public long? Endtimestamp { get; set; }
public long? Duration { get; set; }
[Display(Name = "Average Speed")]
public decimal? AvgSpeed { get; set; }
public decimal? Distance { get; set; }
}
我以前使用的視圖模型來照顧這個,而是作爲公關。微軟分頁文檔分頁需要我用我的模式,因爲它要求的數據,當我通過分頁滾動。
我認爲這將有可能做這樣的事情:
<td>@new DateTime(1970, 1, 1, 0, 0, 0).AddMilliseconds(@Convert.ToDouble(@item.Starttimestamp))</td>
,但我得到下面當我嘗試:
jquery.js:9566 GET http://localhost:1048/Trip/TripTable 500 (Internal Server Error)