private SqlBoolean ToBoolean(ISqlBinary binary)
        {
            if (binary.Length != 1)
            {
                throw new InvalidCastException("Exactly one byte needed to cast to boolean.");
            }

            var b = binary.First();

            if (b != 0 && b != 1)
            {
                throw new InvalidCastException("The first byte of the binary is invalid for a boolean");
            }

            return(b == 1);
        }
Example #2
0
        private SqlBoolean ToBoolean(ISqlBinary binary)
        {
            if (binary.Length != 1)
            {
                throw new InvalidCastException();
            }

            var b = binary.First();

            if (b != 0 && b != 1)
            {
                throw new InvalidCastException();
            }

            return(b == 1);
        }
Example #3
0
        private SqlBoolean ToBoolean(ISqlBinary binary)
        {
            if (binary.Length != 1)
                throw new InvalidCastException();

            var b = binary.First();
            if (b != 0 && b != 1)
                throw new InvalidCastException();

            return b == 1;
        }