UUIDs as returned by databases will be rendered as strings, in different formats depending on the database implementation.

Namespace: ININ.IceLib.Data.TransactionBuilder
Assembly: ININ.IceLib.Data.TransactionBuilder (in ININ.IceLib.Data.TransactionBuilder.dll) Version: 0.0.0.0 (22.3.0.218)

Syntax

C#
public static string AdjustDatabaseUuidString(
	string databaseUuidAsString
)
Visual Basic
Public Shared Function AdjustDatabaseUuidString ( _
	databaseUuidAsString As String _
) As String

Parameters

databaseUuidAsString
Type: System..::..String
A UUID expressed as a string returned by a database.

Return Value

A string of the adjusted UUID.

Remarks

SQL Server will be rendering from the UNIQUEIDENTIFIER type, which is a natural UUID container, while all other databases will be rendering from the relevant binary data type. The main difference (and the reason for this method) is that SQL Server's rendering will be in xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx format (instead of non-dashed formats with possible extra characters), AND the first 3 components of the SQL Server are in little-endian format while the last 2 components are in big-endian format. The problem comes in in that while the native from_string method can read all of the string formats, it assumes that the first 3 components (the 1 4 byte component and the next 2 byte components) are in little-endian format. That works great for SQL Server, but all other formats are essentially big-endian integers. The upshot is that all UUID strings returned by databases that are NOT SQL Server, the uuids generated by the native from_string method will be wrong.

This method assumes that the string passed in is a UUID string as returned by the database. It examines the string and if the string is not in dashed format, then it assumed to be returned by a database other than SQL Server and the first 4 2 hex character byte strings are endian swapped, the next 2 2 hex character byte strings are endian swapped, and the next 2 2 hex character byte strings are endian swapped. In addition, surrounding curly braces, quotes, 'X' and '0x' characters are removed.

This mirrors the function of the I3DBTran StringToGUID() function in eic/src/I3DBTran/I3DBTranUtility/I3DBTranConversions.cpp, which is used to perform the same task for C++-based I3DBTran clients.

Note
WARNING: ONLY APPLY THIS METHOD TO UUID STRINGS BEING RETURNED BY A DATABASE. If you run it against a valid UUID that was formatted without dashes, you will get an unexpected endian swap and your UUID will not be what you expect. If you're not sure you should use this method, you probably shouldn't use it at all. It is intended to be used almost exclusively by codegen created code, or code created by those brave souls that call I3DBTran directly.

Version Information

Supported for IC Server version 2015 R1 and beyond.
For 4.0, supported for IC Server version 4.0 GA and beyond.
For 3.0, supported for IC Server version 3.0 GA and beyond.

See Also