2
我有以下問題。在我的數據庫表中,我有一個名爲ItemDaysNext的顏色(顏色是一個整數)。該值,則總是空,這是確定....正確的sql查詢
我想利用這個coloumn的排序值後...
該保護 - 諮詢熱點工作正常:
var query = from item in items
let today = DateTime.Today
let birthday = item.ItemDate
let next = new DateTime(today.Year, birthday.Month, birthday.Day)
let next2 = next < today ? next.AddYears(1) : next
orderby (next2 - today).Days ascending
select item;
但我會像使用「(next2 - 今天).Days」結果到ItemDaysNext因爲然後我可以排序後更好的Listbox,因爲我可以綁定值...
此聲明不起作用,我成爲一個編譯器錯誤消息(InvalidCastException)
var query = from item in items
let today = DateTime.Today
let birthday = item.ItemDate
let next = new DateTime(today.Year, birthday.Month, birthday.Day)
let next2 = next < today ? next.AddYears(1) : next
orderby (next2 - today).Days ascending
select new { ItemDaysNext = (next2 - today).Days };
我怎麼能做出正確的查詢????
最好的問候所有的答案。