我有日期時間之間的區別計算差值爲int
我計算它在車型
public partial class Park
{
public int parkId { get; set; }
public decimal Longitude { get; set; }
public decimal Latitude { get; set; }
public Nullable<System.DateTime> TimeStart { get; set; }
public Nullable<System.DateTime> TimeEnd { get; set; }
[NotMapped]
public TimeSpan? Difference { get { return TimeEnd - TimeStart; } }
}
並在此之後我把它稱爲後端
var items = ctx.Parks.AsEnumerable().Select(
x => new {
lng = x.Longitude,
lat = x.Latitude,
difference = x.Difference
}).ToList();
但我得到這{ lng = 50.4558539000, lat = 30.5148783000, difference = {00:05:00} }
如果我使用TotalMinutes
,有這
嚴重級代碼說明項目文件行抑制狀態 錯誤CS1061'TimeSpan?'不包含'TotalMinutes'的定義,也沒有包含接受'TimeSpan'類型的第一個參數的擴展方法'TotalMinutes'?可以發現(?是否缺少using指令或程序集引用)GoogleMapsAsp_Net C:\用戶\ nemes \源\回購\ GoogleMapsAsp_Net \ GoogleMapsAsp_Net \ \控制器28 HomeController.cs主動
但我需要的差異在int
分鐘內,我該如何做到這一點?
你想要兩天之間的天數? –
那麼你想要什麼單位?你會期待什麼結果5分鐘的差異?5秒的差距? 5小時的差異? –
具體什麼* int *值應該是'00:05:00'? – David