After some banging of my head on a wall, I found what I believe to be a bug in Oracle's .NET data provider (or ODP). Or, at the very least, it is some non-intuitive behavior. We have a byte-based enum that is stored in the db for a reporting tool. As we all know, bytes are unsigned, but somehow a bunch of my values were negative in the database. Closer inspection indicated that my values had been treated as if byte was signed. After a thorough review of my code, I fired up Reflector to dig through the ODP code. After a little while, It became clear ODP was treating my byte as if it were signed. Although the actual problem is in unmanaged world, here's a troubling method that's called during the binding process:
internal unsafe void SetPrmValCtx(byte b, int index)
{
*(((sbyte*) (this.m_pOpoPrmValCtx.pBltVal + index))) = b;
}
It was easy enough to work around, since our API is several layers removed from ODP itself. But annoying nonetheless, especially since using an sbyte (signed byte) as a parameter value will throw an exception. Just thought Google might be able to help someone else out in the future using this information. in the meantime, I'll make sure Oracle knows about this little annoyance.