Hi guys, I am trying to insert multiple records in a table (salesorder), and after it I have to update a column (invoiceno) in another table (id). Please guide me, I'm new to LINQ, here my code below.
Code:
using (TransactionScope tTransaction = new TransactionScope())
            {
                //Loop throughout the list and store in the database

                for (iIndex = 0; iIndex < lvItems.Items.Count; iIndex++)
                {
                    salesorder item = new salesorder();
                    item.invoiceno = strInvoiceNo;
                    item.barcode = lvItems.Items[iIndex].SubItems[0].Text;
                    item.itemprice = decimal.Parse(lvItems.Items[iIndex].SubItems[2].Text);
                    item.itemqty = int.Parse(lvItems.Items[iIndex].SubItems[3].Text);
                    item.customerid = txtCustomerID.Text.Trim();
                    dbCustomerInfo.salesorders.InsertOnSubmit(item);
                }

                //Update invoice number in ids
                id ids = new id();
                ids = (from i in dbCustomerInfo.ids
                       select i).Single();
                ids.invoiceno = ids.invoiceno + 1;

                //Write to database
                dbCustomerInfo.SubmitChanges();

                //Commit
                tTransaction.Complete();

                MessageBox.Show("Sales order has been processed.", "::New Record::", MessageBoxButtons.OK, MessageBoxIcon.Information);
                
            }