我一直得到之下,而嘗試使用實體框架 檢索數據並分配給我的自定義類客戶無法轉換源類型system.nullable目標類型爲int
不能轉換源類型「system.nullable」錯誤消息爲目標類型「詮釋」
CUSTOMERNUMBER和路線都的Int32,並在數據庫中的字段的數據類型的允許空值
select new Customer()
{
AccountListId = j.cost1,
Csr = j.cost2,
CustomerName = j.cost3,
Address = j.cost4,
Telephone = j.cost5,
Contact = j.cost6,
CustomerNumber = j.cost7,
Branch = j.cost8,
Route = j.cost9,
}).ToList<Customer>();
我該如何處理呢?
你想分配給'Int32'領域,如果從數據庫中值爲'null'什麼。顯然,'null'是無效的。你想設置「0」還是「-1」,或者是什麼? – sstan
可能重複的[如何將nullable int轉換爲int](http://stackoverflow.com/questions/5995317/how-to-convert-nullable-int-to-int) –