How to generate unique order number?

前端 未结 6 1637
情话喂你
情话喂你 2021-02-06 06:59

I\'m looking for a good way to generate a unique order ID. Can you see any problems with the code below?

int customerId = 10000000;

long ticks = DateTime.UtcNow         


        
6条回答
  •  长情又很酷
    2021-02-06 07:19

    IF you're using SQL Server, you should really look up the IDENTITY specification. It lets you do this with ease and speed.

    Your solution isn't unique because things can happen so fast in the system that two processes, either running in sequence or concurrently, can get the same tick value.

提交回复
热议问题