How to generate unique order number?

前端 未结 6 1748
情话喂你
情话喂你 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:36

    What about having an IDENTITY field in the database do it for you?

    It will also have the advantage that deleted/canceled order numbers won't be reused (which is good or may even be required for accounting).

提交回复
热议问题