Hi. I have an Invoice table (and a SubSonic 'Invoice' ActiveRecord) with an InvoiceNumebr column that needs to have unique numbers. I am trying to GetTheNextAvailableNumber() inside of a TransactionScope using block. This works. What I'm not sure of is, what happens if 5, or 50 different users try to create an Invoice at approx. the same time, the method would return the same number for all 5 or 50 users if they don't save the invoice object until later.
The GetTheNextAvailableNumber() method which called inside the TransactionScope block uses a Subsonic Select query with a MAX() to get the maximum number, then adds 1. The column itself does have a UNIQUE index!
Would the Transaction's isolation level default (Serializable) make sure that each of those gets a unique number? Or is there a more clever mechanism to achieve that? The column cannot have an IDENTITY, since the PK column InvoiceID already has it.