c# - Getting a new unique number for a column in table -


i'm creating online payment system. bank requires unique invoice number. suppose table:

public class onlinepaymentinfo {     public onlinepaymentinfo()     {         orders = new list<order>();     }      [key]     public int id { get; set; }      [required]     public virtual order firstorder { get; set; }     public ilist<order> orders { get; set; }     public int invoicenumber { get; set; }     public string transactionreferenceid { get; set; } } 

now order might change. once can't send payment info same invoice id bank online payment. want new unique invoice id. can query database getting maximum number, this:

var newid = db.onlinepayments.max(op => op.invoicenumber) + 1; 

but i'm wondering if best way this.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -