Convert byte array from Oracle RAW to System.Guid?

前端 未结 3 1173
失恋的感觉
失恋的感觉 2021-01-02 04:29

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 c

3条回答
  •  温柔的废话
    2021-01-02 04:58

    It turns out that the issue was the byte order you get in Guid.ToByteArray() and not Oracle itself. If you take the Guid "11223344-5566-7788-9900-aabbccddeeff" and call ToByteArray() on it, you get "44332211665588779900AABBCCDDEEFF". If you then pass that byte array back into the constructor for Guid, you get the original Guid. My mistake was trying to query the Oracle database by the original Guid format (with the dashes removed) instead of the result of the ToByteArray() call.

    I still have no idea why the bytes are ordered that way, but it apparently has nothing to do with Oracle.

提交回复
热议问题