Using OpenPetra's DataAccess Objects

From OpenPetra Wiki
Revision as of 11:13, 2 August 2011 by Christiankatict (talk | contribs)
Jump to navigation Jump to search

Purpose of OpenPetra's DataAccess Objects

OpenPetra's DataAccess Objects form an Object-Relational Mapper (ORM [1]). The ORM relieves the programmer from the need to write SQL commands and provides compile-time checks as the DataAccess Objects expose Methods with Typed Arguments. Contrast that with SQL commands, which are simple strings embedded in source code. No compile-time checks (such as for correctness of syntax and existence of a certain DB table) can be done on those!

OpenPetra's DataAccess Objects are auto-generated from the \db\petra.xml file and use the RDMBS-agnostic Database Access Object for the execution of SQL commands (DataAccess Objects are therefore not tied to a specific RDBMS!).

An overview of OpenPetra's DataAccess Objects can be found here.


Reading Data From The Database

Data is read using one of the many Load... Methods of a DataAccess Object.

The following Methods exist:

LoadAll Methods (overloaded)

TODO

LoadByPrimaryKey Methods (overloaded)

TODO

LoadByUniqueKey Methods (overloaded)

TODO

LoadViaForeignKey Methods (overloaded)

TODO

LoadVia... Methods (overloaded)

TODO

LoadVia...Template Methods (overloaded)

TODO

LoadUsingTemplate Methods (overloaded)

TODO


Counting of Data And Checking For Existence of Data In The Database

Counting of Data In The Database

CountAll Method

TODO

CountUsingTemplate Methods (overloaded)

TODO

CountViaForeignKey Methods (overloaded)

TODO

CountVia... Method

TODO

CountVia...Template Methods (overloaded)

TODO


Checking For Existence of Data In The Database

Exists Method

Checks if a row exists with the specified primary key.


Writing And Deleting Data From The Database

SubmitChanges Methods (overloaded)

TODO

AddOrModifyRecord Method

If a record with the specified primary key already exists in the database, that record will be updated, otherwise a new record will be added.

DeleteByPrimaryKey Method

TODO

DeleteUsingTemplate Methods (overloaded)

TODO


Other Functionalities

GetSafeValue Methods (overloaded)(from Ict.Common.Data.TTypedDataAccess)

This Method returns either a valid Object or System.DBNull.

NotEquals Method (from Ict.Common.Data.TTypedDataAccess)

Compares the original and the current value of a DataColumn in a DataRow.

RowCount Property (from Ict.Common.Data.TTypedDataAccess)

Tells how many DataRows are in the current query or have been processed.