partial void DeleteXERO_PAYMENT(XERO_PAYMENT instance);
 partial void InsertXERO_PAYMENT(XERO_PAYMENT instance);
 partial void UpdateXERO_PAYMENT(XERO_PAYMENT instance);
        private void CreatePaymentsInDatabase(List<Payment> paymentsToUpdate)
        {
            using (DataClassesDataContext context = new DataClassesDataContext())
            {
                List<XERO_PAYMENT> xeroPayments = new List<XERO_PAYMENT>();
                foreach (var payment in paymentsToUpdate)
                {
                    XERO_PAYMENT xeroPayment = new XERO_PAYMENT();
                    xeroPayment.AccountCode = payment.Account.Code;
                    xeroPayment.Amount = payment.Amount;
                    xeroPayment.CurrencyRate = payment.CurrencyRate;
                    xeroPayment.Date = payment.Date;
                    xeroPayment.InvoiceNumber = payment.Invoice.Number;
                    xeroPayment.IsReconciled = payment.IsReconciled;
                    xeroPayment.PaymentStatus = payment.Status.ToString();
                    xeroPayment.PaymentType = payment.Type.ToString();
                    xeroPayment.Reference = payment.Reference;
                    xeroPayment.XeroId = payment.Id.ToString();
                    xeroPayment.UpdateDate = payment.UpdatedDateUtc.GetValueOrDefault();

                    xeroPayments.Add(xeroPayment);
                }

                context.XERO_PAYMENTs.InsertAllOnSubmit(xeroPayments);
                context.SubmitChanges();
            }
        }