Is there a way to get the functionality of the Sql Server 2005+ Sequential Guid generator without inserting records, to read it back both ways or to call win dll win? I saw someone respond using rpcrt4.dll, but I'm not sure if this will work from my hosted production environment.
Edit: Work with @John Boker answer. I tried turning it into a GuidComb generator instead of relying on the last Guid generated, other than the launch. This is for seed instead of starting with Guid.Empty that I use
public SequentialGuid() { var tempGuid = Guid.NewGuid(); var bytes = tempGuid.ToByteArray(); var time = DateTime.Now; bytes[3] = (byte) time.Year; bytes[2] = (byte) time.Month; bytes[1] = (byte) time.Day; bytes[0] = (byte) time.Hour; bytes[5] = (byte) time.Minute; bytes[4] = (byte) time.Second; CurrentGuid = new Guid(bytes); }
I based on the comments on
// 3 - the least significant byte in Guid ByteArray [for SQL Server ORDER BY clause] // 10 - the most significant byte in Guid ByteArray [for SQL Server ORDERY BY clause] SqlOrderMap = new[] {3, 2, 1, 0, 5, 4, 7, 6, 9, 8, 15, 14, 13, 12, 11, 10};
Does this mean that I want the seeds of the guide using DateTime, or does it look like I should do this in the reverse order and work backward from the end of the SqlOrderMap indexes? I'm not too worried that they will interrupt the search call at any time when the initial guid is created, since it will only occur during reuse of the application.
c # guid sequence
Chris Marisic Nov 17 '09 at 21:36 2009-11-17 21:36
source share