SequentialGuidProviderprovides functionality for server side generation sequential GUID (COMB GUID).
The basic setup is:
AddSequentialGuidProviderextension method performs registration of SequentialGuidProvider with specified settings.
ISequentialGuidProviderservice and use it:
public class FileService : ICustomService
private readonly ISequentialGuidProvider _sequentialGuidProvider;
public FileService(ISequentialGuidProvider _sequentialGuidProvider)
=> _sequentialGuidProvider = _sequentialGuidProvider;
public void Upload()
Guid fileId = _sequentialGuidProvider.GetSequentialGuid(SequentialGuidType.String);
GetSequentialGuidmethod generating sequential GUID with following types:
SequentialGuidType.String- The first six bytes are in sequential order, and the remainder is random. Inserting these values into a database that stores GUIDs as strings (such as MySQL) should provide a performance gain over non-sequential values. This type should be used with MySQL or PostgreSQL database.
SequentialGuidType.Binary- The first two blocks are "jumbled" due to having all their bytes reversed (this is due to the endianness issue discussed earlier). If we were to insert these values into a text field (like they would be under MySQL or PostgreSQL), the performance would not be ideal. This type should be used with Oracle database.
SequentialGuidType.Ending- The last six bytes are in sequential order, and the rest is random. This type should be used with MS SQL Server database.