A .NET library to generate sequential GUIDs, similar to SQL Server's newsequentialid()
.
It's a drop-in replacement for System.Guid.NewGuid()
, focusing on performance and low allocation.
Caution
The downside is that it's not as unique as System.Guid.NewGuid()
and crypotographically insecure.
So be sure to understand the trade-offs before using it.
With the SequentialGuidType
enum, you can choose between 3 different types of sequential GUIDs:
AsBinary
The sequential part is at the beginning of the GUID, similar to Oracle'sSYS_GUID()
.AsString
(Default)
The sequential part is at the beginning of the GUID.AtEnd
The sequential part is at the end of the GUID, similar to SQL Server'snewsequentialid()
.
dotnet add package NetEvolve.SequentialGuid
using NetEvolve.SequentialGuid;
Guid guid = SequentialGuidFactory.NewGuid(); // Default is SequentialGuidType.AsString
// or
Guid guid = SequentialGuidFactory.NewGuid(SequentialGuidType.AsBinary);