How is it usually returned as a byte? If so, just do unbox and then convert:
(int)(byte) reader["column"];
or just enable the conversion in a natural way:
int x = (byte) reader["column"];
or do the same with strongly typed methods:
int x = reader.GetByte(column);
Adjust this value to sbyte
or short
or something else if I am mistaken regarding its comparison with byte
. You could do the conversion on the SQL Server side, but I would personally do it on the client side instead and simplify the SQL.
Jon Skeet Dec 17 '09 at 14:24 2009-12-17 14:24
source share