C# Class DSShared.DB_Access.Access_DBTable

Provides basic support for insert, update and delete operations. Properties of the extended class that are tagged with DBColumnAttributes will be reflected upon so that the system knows which properties map to what columns in your table Before creation of a an object that extends this class, make sure your type is registered with the DBTableTypeCache
Inheritance: IComparable
Show file Open project: pmprog/OpenXCOM.Tools

Protected Properties

Property Type Description
myType DSShared.DB.DBTableType

Public Methods

Method Description
Access_DBTable ( string tableName ) : System

Constructor for an access table

CompareTo ( object other ) : int

It is up to the implementing class to determine how this table compares to other tables

Delete ( ) : void

Opens a connection to the database and calls Delete(OleDbConnection conn,OleDbTransaction trans)

Delete ( System.Data.OleDb.OleDbConnection conn, System.Data.OleDb.OleDbTransaction trans ) : void

Deletes a row based on the AutoNumber property of the internal DBTableType. An exception will be thrown if your class does not have an autonumber attribute set and this method is not overridden

Delete ( System.Data.OleDb.OleDbConnection conn, System.Data.OleDb.OleDbTransaction trans, string table ) : void

Creates and performs a delete query

Equals ( object other ) : bool

It is up to the implementing class to determine how this table equals other tables

GetAll ( System.Data.OleDb.OleDbConnection conn, System.Data.OleDb.OleDbTransaction trans, string table, bool cache ) : ArrayList

Retrieves all rows from a single table according to the columns specified The order of items is based on the order retrieved from the query Generally, this method does a SELECT * FROM table

GetAll ( string table, bool cache ) : ArrayList

Calls GetAll(table,cache,null)

GetAllHash ( System.Data.OleDb.OleDbConnection conn, System.Data.OleDb.OleDbTransaction trans, string table, bool cache ) : Hashtable

Retrieves all rows from a single table according to the columns specified The keys of the hashtable are autonumber values which are retrieved from properties tagged with a DBColumn value of true for autoNumber

GetAllHash ( string table, bool cache ) : Hashtable

Opens a connection and transaction to the database and calls GetAllHash(OleDbConnection conn,OleDbTransaction trans,string table,bool cache,params WhereCol[] whereQuery) with it. Upon success, the transaction is committed and the connection closed

GetHashCode ( ) : int

It is up to the implementing class to determine the hash code of this table

Insert ( System.Data.OleDb.OleDbConnection conn, System.Data.OleDb.OleDbTransaction trans ) : void

Performs an insert operation. It is up to the user to ensure that this operation will not fail (ie: calling insert twice on the same object)

PrintTableInfo ( ) : void

Prints table information to the Console

Save ( ) : void

Opens a database connection and transaction and calls Save(Access_DBInterface.Instance.Connection,trans)

Save ( System.Data.OleDb.OleDbConnection conn, System.Data.OleDb.OleDbTransaction trans ) : void

It is up to the implementing class to determine how this table is saved, either with an Insert() or an Update()

Update ( System.Data.OleDb.OleDbConnection conn, System.Data.OleDb.OleDbTransaction trans ) : void

Updates a row based on the AutoNumber property

Protected Methods

Method Description
FinishGet ( System.Data.OleDb.OleDbConnection conn, System.Data.OleDb.OleDbTransaction trans ) : void

Once all the rows of a table have been retrieved with GetAll(), this method gets called to allow the table to perform any additional information retrieval necessary This is the time to link up fields in other tables that have been cached

Method Details

Access_DBTable() public method

Constructor for an access table
public Access_DBTable ( string tableName ) : System
tableName string Name of the table in the database this object represents
return System

CompareTo() public abstract method

It is up to the implementing class to determine how this table compares to other tables
public abstract CompareTo ( object other ) : int
other object
return int

Delete() public method

Opens a connection to the database and calls Delete(OleDbConnection conn,OleDbTransaction trans)
public Delete ( ) : void
return void

Delete() public method

Deletes a row based on the AutoNumber property of the internal DBTableType. An exception will be thrown if your class does not have an autonumber attribute set and this method is not overridden
public Delete ( System.Data.OleDb.OleDbConnection conn, System.Data.OleDb.OleDbTransaction trans ) : void
conn System.Data.OleDb.OleDbConnection
trans System.Data.OleDb.OleDbTransaction
return void

Delete() public static method

Creates and performs a delete query
public static Delete ( System.Data.OleDb.OleDbConnection conn, System.Data.OleDb.OleDbTransaction trans, string table ) : void
conn System.Data.OleDb.OleDbConnection Connection to use for the delete
trans System.Data.OleDb.OleDbTransaction Transaction to use for the delete
table string Name of the table to delete
return void

Equals() public abstract method

It is up to the implementing class to determine how this table equals other tables
public abstract Equals ( object other ) : bool
other object
return bool

FinishGet() protected method

Once all the rows of a table have been retrieved with GetAll(), this method gets called to allow the table to perform any additional information retrieval necessary This is the time to link up fields in other tables that have been cached
protected FinishGet ( System.Data.OleDb.OleDbConnection conn, System.Data.OleDb.OleDbTransaction trans ) : void
conn System.Data.OleDb.OleDbConnection Connection that was used for the GetAll()
trans System.Data.OleDb.OleDbTransaction Transaction used for the GetAll()
return void

GetAll() public static method

Retrieves all rows from a single table according to the columns specified The order of items is based on the order retrieved from the query Generally, this method does a SELECT * FROM table
public static GetAll ( System.Data.OleDb.OleDbConnection conn, System.Data.OleDb.OleDbTransaction trans, string table, bool cache ) : ArrayList
conn System.Data.OleDb.OleDbConnection Connection to use
trans System.Data.OleDb.OleDbTransaction Transaction to use
table string Table name
cache bool If true, cache'ing will be used
return System.Collections.ArrayList

GetAll() public static method

Calls GetAll(table,cache,null)
public static GetAll ( string table, bool cache ) : ArrayList
table string Table name
cache bool If true, cache'ing will be used
return System.Collections.ArrayList

GetAllHash() public static method

Retrieves all rows from a single table according to the columns specified The keys of the hashtable are autonumber values which are retrieved from properties tagged with a DBColumn value of true for autoNumber
public static GetAllHash ( System.Data.OleDb.OleDbConnection conn, System.Data.OleDb.OleDbTransaction trans, string table, bool cache ) : Hashtable
conn System.Data.OleDb.OleDbConnection Connection to the database
trans System.Data.OleDb.OleDbTransaction Transaction object that is open and paired with the connection
table string Name of the table to get all the rows from
cache bool If true, values will be retrieved from the cache if available
return System.Collections.Hashtable

GetAllHash() public static method

Opens a connection and transaction to the database and calls GetAllHash(OleDbConnection conn,OleDbTransaction trans,string table,bool cache,params WhereCol[] whereQuery) with it. Upon success, the transaction is committed and the connection closed
public static GetAllHash ( string table, bool cache ) : Hashtable
table string table name
cache bool if the table does not change frequently, you should set this to true
return System.Collections.Hashtable

GetHashCode() public abstract method

It is up to the implementing class to determine the hash code of this table
public abstract GetHashCode ( ) : int
return int

Insert() public method

Performs an insert operation. It is up to the user to ensure that this operation will not fail (ie: calling insert twice on the same object)
public Insert ( System.Data.OleDb.OleDbConnection conn, System.Data.OleDb.OleDbTransaction trans ) : void
conn System.Data.OleDb.OleDbConnection
trans System.Data.OleDb.OleDbTransaction
return void

PrintTableInfo() public method

Prints table information to the Console
public PrintTableInfo ( ) : void
return void

Save() public method

Opens a database connection and transaction and calls Save(Access_DBInterface.Instance.Connection,trans)
public Save ( ) : void
return void

Save() public method

It is up to the implementing class to determine how this table is saved, either with an Insert() or an Update()
public Save ( System.Data.OleDb.OleDbConnection conn, System.Data.OleDb.OleDbTransaction trans ) : void
conn System.Data.OleDb.OleDbConnection Connection to use for the save
trans System.Data.OleDb.OleDbTransaction Transaction to use for the save
return void

Update() public method

Updates a row based on the AutoNumber property
public Update ( System.Data.OleDb.OleDbConnection conn, System.Data.OleDb.OleDbTransaction trans ) : void
conn System.Data.OleDb.OleDbConnection Connection to use
trans System.Data.OleDb.OleDbTransaction Transaction to use
return void

Property Details

myType protected property

The DBTableType that was setup upon initial table registration
protected DBTableType,DSShared.DB myType
return DSShared.DB.DBTableType