Get Auto generated ID using c# & entity Framwork with prefix

 string prefix = "PO";
                string a = "0000000001";
                string invNo = prefix + a;
                var inv = (from p in db.PurchaseOrders
                           where p.PONO.Contains(prefix)
                           orderby p.ID descending
                           select p.PONO).FirstOrDefault();
                if (inv != null)
                {
                    a = inv.Substring(prefix.Length);
                    invNo = prefix + (Convert.ToDecimal(a) + 10000000001).ToString().Substring(1);

                }

Comments

Popular posts from this blog

Provision AWS EC2 Instance and RDS with Terraform, and Deploy Spring Boot App to EC2 Instance via GitHub Action Pipeline

JQuery UI Autocomplete, custom HTML structure for result?

Easy Ui Jquery easyui-textbox change onChange event