-1
我正在開發一個MVC應用程序。我在SQL表中有一個時間戳列。我有一個查詢從數據庫中檢索所有數據。我正在使用LINQ。如何將sql時間戳分配給linq查詢中的c#變量?
下面是我的查詢:
obj = (from c in entityObject.NCT_ProcessAudit.AsNoTracking()
join proc in entityObject.NCT_Process_Settings on c.process_id equals proc.ID
select new returnObject
{
ID = c.ID,
process_id = c.process_id,
icon_id = c.icon_id,
dispaly_order = c.dispaly_order,
updated = c.updated, //c. updated timestamp in sql and updated is datetime as public Nullable<System.DateTime> updated { get; set; }
output = c.output
}).OrderByDescending(a => a.updated).ToList();
當我運行上面的查詢,我得到以下錯誤
指定的強制轉換從物化「System.Byte []」類型爲可空「 System.DateTime'類型無效。
我可以在這裏得到一些幫助。任何幫助,將不勝感激。謝謝。
:-)取代。 returnObject類中更新的類型是什麼? – A3006
謝謝。 public Nullable updated {get;組; } –
你真的不應該命名你的類'returnObject' –