WALTER | Workable Algorithms for Location-aware Transmission, Encryption Response

SequentialGuid Class

The SequentialGuid class is used for generating unique sequential GUIDs. This can be particularly useful for databases where GUIDs are used as primary keys do facilitate row insert speed reducing fragmentation and overhead on indexing maintenance.

Namespace:  Walter
Assembly:  Walter (in Walter.dll)

Syntax


[DebuggerDisplayAttribute]
public sealed class SequentialGuid

Remarks


The class calculates GUIDs that are sequential within a given time frame defined by a start and end date. The guid generated are sequential and are therefor ordered ascending and could be guessed, not as simple as integer increments but are guessing the ID is possible.

Examples


Introduction to Sequential GUID Tests

These tests are designed to verify the behavior of GUIDs generated using our custom SequentialGuid.NewGuid() method. This method is intended to create globally unique identifiers (GUIDs) that are sequential, which can be beneficial for database indexing and retrieval performance. We have two specific tests to validate the essential characteristics of our GUID generation method:

  1. Test for Uniqueness with the Same Timestamp (SequentialGuidTest):
  2. Test for Sequential Order (SortOrderFirstIsBeforeSecond):
Test for Uniqueness with the Same Timestamp
[TestMethod()]
   public void SequentialGuidTest()
   {
        // Arrange
       var time = DateTime.UtcNow;

       // Act
       var guid1 =SequentialGuid.NewGuid(time);
       var guid2 = SequentialGuid.NewGuid(time);

       // Assert
       Assert.AreNotEqual(guid1, guid2);
   }
Test for Sequential Order
[TestMethod]
   public void SortOrderFirstIsBeforeSecond()
   {
       // Arrange
       var first = SequentialGuid.NewGuid();
       var second = SequentialGuid.NewGuid();

       // Act
       var result = first.CompareTo(second);

       // Assert
       Assert.IsTrue(result< 0);
   }

Inheritance Hierarchy


Object
  Walter..::..SequentialGuid