我在上获得Unable to cast object of type 'System.Int64' to type 'System.Int32'
item.ItemCount = reader.GetInt32(reader.GetOrdinal("amount"));
我试过了:
item.ItemCount = reader.GetInt64(reader.GetOrdinal("amount"));
但我得到了:
Error CS0266
Cannot implicitly convert type 'long' to 'int'.
An explicit conversion exists (are you missing a cast?)
字段是bigint
,这是我第一次使用。网
您必须使用GetInt64
item.ItemCount = reader.GetInt64(reader.GetOrdinal("amount"));
SQLbigint
等效于。NETlong
,GetInt64
返回long
,而GetInt32
返回int
。
有关更多详细信息,请参阅本文档。