Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
GuidCOMB
Message
De
25/05/2011 04:34:58
 
 
À
25/05/2011 02:15:01
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Versions des environnements
Environment:
C# 4.0
OS:
Windows Server 2008
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01510431
Message ID:
01511711
Vues:
45
>Hi
>Found solutions as below
>
>
>            byte[] ticksAsBytes = BitConverter.GetBytes(DateTime.Now.Ticks);
>            Array.Reverse(ticksAsBytes);
>            int increment = Interlocked.Increment(ref guidCounter);
>            byte[] currentAsBytes = BitConverter.GetBytes(increment);
>            Array.Reverse(currentAsBytes);
>            byte[] bytes = new byte[16];
>            Array.Copy(ticksAsBytes, 0, bytes, 0, ticksAsBytes.Length);
>            Array.Copy(currentAsBytes, 0, bytes, 12, currentAsBytes.Length);
>            Array.Copy(GuidUtil.machineId, 0, bytes, 8, machineId.Length);
>
>            //return bytes.TransfromToGuidWithProperSorting();
>
>            return new Guid(bytes);
>
>Source: http://ayende.com/blog/4643/createsequetialuuid-answer
>
>But I didn't transform it using TransfromToGuidWithProperSorting() because found that it doesn't sorted actually by dump the generated guid to SQL table and added clustered index to the field.

Hi,
I'm not clear on your last sentence. The algorithm for TranfromToGuidWithProperSorting() is the same as that embedded in the version I referenced. I thought the whole point of the exercise was to produce a sequential GUID as used by the SQL ORDER BY clause.
Oh - and did you read the suggestion to use DateTime.UtcNow to avoid time change issues ?
Regards,
Viv
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform