Is there a .NET equivalent to SQL Server's newsequentialid()

前端 未结 10 2177
孤城傲影
孤城傲影 2020-12-02 10:47

We use GUIDs for primary key, which you know is clustered by default.

When inserting a new row into a table it is inserted at a random page in the table (because GUID

10条回答
  •  遥遥无期
    2020-12-02 11:06

    It should be possible to create a sequential GUID in c# or vb.net using an API call to UuidCreateSequential. The API declaration (C#) below has been taken from Pinvoke.net where you can also find a full example of how to call the function.

    [DllImport("rpcrt4.dll", SetLastError=true)]
    static extern int UuidCreateSequential(out Guid guid);
    

    The MSDN article related to the UuidCreateSequential function can be found here which includes the prerequisites for use.

提交回复
热议问题