Convert byte array from Oracle RAW to System.Guid?
Posted
by Cory McCarty
on Stack Overflow
See other posts from Stack Overflow
or by Cory McCarty
Published on 2010-04-19T13:30:18Z
Indexed on
2010/04/19
13:33 UTC
Read the original article
Hit count: 677
My app interacts with both Oracle and SQL Server databases using a custom data access layer written in ADO.NET using DataReaders. Right now I'm having a problem with the conversion between GUIDs (which we use for primary keys) and the Oracle RAW datatype. Inserts into oracle are fine (I just use the ToByteArray() method on System.Guid). The problem is converting back to System.Guid when I load records from the database. Currently, I'm using the byte array I get from ADO.NET to pass into the constructor for System.Guid. This appears to be working, but the Guids that appear in the database do not correspond to the Guids I'm generating in this manner.
I can't change the database schema or the query (since it's reused for SQL Server). I need code to convert the byte array from Oracle into the correct Guid.
© Stack Overflow or respective owner