Convert byte array from Oracle RAW to System.Guid?

前端 未结 3 1176
失恋的感觉
失恋的感觉 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条回答
  •  旧时难觅i
    2021-01-02 05:17

    I just had this same issue when storing and reading Guids from Oracle.

    If your app needs to store and read Guids from Oracle, use the FlipEndian function from this thread:

    .NET Native GUID conversion

    Byte[] rawBytesFromOracle;
    Guid dotNetGuid = new Guid(rawBytesFromOracle).FlipEndian();
    

    The flip is only required when reading back from Oracle.

    When writing to Oracle use Guid.ToByteArray() as normal.

    I spent TOO much time trying to get this simple task accomplished.

    Steve

提交回复
热议问题