/// <summary> /// Return all the customers in the DB. Does not close the connection, so call CloseDbConnection() or Dispose(). /// </summary> /// <returns></returns> public List<Customer> Customers() { OpenDbConnection(); var dto = new CustomerDTO(); return dto.SelectAll(_dbConnection); }
/// <summary> /// Save (Insert/Update/Delete) the Customers in the EntityInfo objects /// </summary> /// <param name="conn">Open database connection</param> /// <param name="entityInfos">EntityInfo.Entity is Customer</param> public void SaveCustomers(SqlConnection conn, List<EntityInfo> entityInfos) { var dto = new CustomerDTO(); foreach (var info in entityInfos) { var customer = info.Entity as Customer; switch (info.EntityState) { case EntityState.Added: dto.Insert(conn, customer); break; case EntityState.Modified: dto.Update(conn, customer); break; case EntityState.Deleted: dto.Delete(conn, customer); break; } } }