Skip to main content
3 of 4
deleted 706 characters in body
Mathematics
  • 934
  • 2
  • 8
  • 27

CRUD strongly typed data access

I have a data access class,

using CompanyX.DataAccess.CompanyXTableAdapters;

namespace CompanyX.DataAccess
{
    public class CompanyXDataAccess
    {
        #region Invoice
        
        public CompanyX.InvoiceDataTable GetInvoiceByID(int ID)
        {
            InvoiceTableAdapter ta = new InvoiceTableAdapter();
            using (ta.Connection = new SqlConnection(DB.GetReaderConnectionString()))
            {
                return ta.GetByID(ID);
            }
        }

        public CompanyX.InvoiceDataTable GetInvoice(string userSID)
        {
            InvoiceTableAdapter ta = new InvoiceTableAdapter();
            using (ta.Connection = new SqlConnection(DB.GetReaderConnectionString()))
            {
                return ta.Get(userSID);
            }
        }
        
        public void DeleteInvoice(int ID)
        {
            InvoiceTableAdapter ta = new InvoiceTableAdapter();
            using (ta.Connection = new SqlConnection(DB.GetWriterConnectionString()))
            {
                ta.Delete1(ID);
            }
        }

        public void UpdateInvoice(Invoice m)
        {
            InvoiceTableAdapter ta = new InvoiceTableAdapter();
            using (ta.Connection = new SqlConnection(DB.GetWriterConnectionString()))
            {
                ta.Update1(m.ID, ... n numbers of params ..., m.ModifiedBy);
            }
        }
        
        #endregion
        
        // more regions for modules come in here with CRUD and other queries
    }
}

[![enter image description here][1]][1]

Questions

Is there anyway I can improve this code without losing any performance ?

Please Note

Mathematics
  • 934
  • 2
  • 8
  • 27