Just use always your standard GUID
in .NET...
When you want to insert some GUID
into Oracle you just call Guid.ToString ( "N")
and feed that string to Oracle (in this example the param name is MyNETVAL
):
INSERT INTO MyTable ( MyRAWCol)
SELECT HEXTORAW (SUBSTR (MyNETVal, 6, 2) || SUBSTR (MyNETVal, 4, 2) || SUBSTR (MyNETVal, 2, 2) || SUBSTR (MyNETVal, 0, 2) || SUBSTR (MyNETVal, 10, 2) || SUBSTR (MyNETVal, 8, 2) || SUBSTR (MyNETVal, 14, 2) || SUBSTR (MyNETVal, 12, 2) || SUBSTR (MyNETVal, 16, 16)) FROM DUAL;
When you read a RAW
from Oracle you use:
SELECT
SUBSTR (HexV, 6, 2) || SUBSTR (HexV, 4, 2) || SUBSTR (HexV, 2, 2) || SUBSTR (HexV, 0, 2) || SUBSTR (HexV, 10, 2) || SUBSTR (HexV, 8, 2) || SUBSTR (HexV, 14, 2) || SUBSTR (HexV, 12, 2) || SUBSTR (HexV, 16, 16) AS MyNETVal
FROM (SELECT RAWTOHEX (MyRAWCol) HexV FROM MyTable);
Then you can feed the returned MyNETVal
into new Guid (MyNETVal)
.
This way your code always deals with the .NET format and the byte switching occurs in the Oracle-DB... you don't polute your code with conversion code and can keep the code code the same when switchig to other DBs - just change the SQL and you are up and running... the SQL could get simpler with other DBs because some of them follow the GUID format of Windows...