(Fully qualified class name: Datarabbit. relation. itableaccesser )
Orm cannot do everything. Some database access still needs to be performed based on the relationship. I think it is unwise for pure ORM frameworks that do not provide data access operations based on the relationship. In datarabbit, Orm-based access and relational-based data access account for half of the sky, which makes it impossible for us to use Orm, you can turn to the relational accessors. Datarabbit. the classes and interfaces in the relation namespace are used to provide relational-based database access operations, including: the database's relation accesser (irelationaccesser) and the table's relation accesser (itableaccesser) and ispaccesser for stored procedures. This article first introduces itableaccesser.
Like all other accessors in datarabbit, itableaccesser also inherits from itransactionaccesser, which is used
ForA specificTable For relational-based data access. We can obtain the itableaccesser reference from idataaccesser, the entry point of datarabbit. For example, we want to obtain the itableaccesser for the student table. We can do this:ItableaccesserStutableaccesser = Dataaccesser. gettableaccesser ( " Student " , Null );
Like the ORM accessors, all relational accessors shield users from the idbcommand, idbconnection, and other objects in the strata, you do not have to worry about the cumbersome operations such as opening a connection, executing commands, and closing a connection. You only need to submit the SQL statement to the accessor for execution. For example, if we want to delete all student older than 30, we can use itableaccesser to do this: ItableaccesserStutableaccesser = Dataaccesser. gettableaccesser ( " Student " , Null );
Stutableaccesser.Delete( String . Format ( " Where {0}> '30' " ,Student. _ Age ));
The relational accessors need to write their own SQL statements, especially the WHERE clause used for searching. Because they support handwritten SQL statements, relational accessors can perform more complex database operations. Note: When introducing the ORM accessors, we often use filters to represent conditions. However, filters and ifiltertree can only be used in the ORM accessors, they cannot be used in relational accessors.
The idataaccesser interface is relatively simple. Let's take a look at its full picture. Then you will know the meaning of each method in this interface: Public Interface Itableaccesser: itransactionaccesser
{
# Region Tablename
/// <Summary>
/// Tablename target table name
/// </Summary>
String Tablename { Get ;}
# Endregion
# Region Commitdata
/// <Summary>
/// Commitdata: Submit the changes in the able to the database.
/// </Summary>
Void Commitdata (datatable DT );
# Endregion
# Region Delete
/// <Summary>
/// Delete: delete all records in the target table that meet the where Condition
/// </Summary>
Void Delete ( String Where );
# Endregion
# Region Clear
/// <Summary>
/// Clear clear target table
/// </Summary>
Void Clear ();
# Endregion
# Region Insert
/// <Summary>
/// Insert stores row in the database
/// </Summary>
Void Insert (datarow row );
# Endregion
# Region Get
/// <Summary>
/// Get
/// </Summary>
DatasetGet ( String Where );
/// <Summary>
/// Getone returns the first record that meets the where condition.
/// </Summary>
DatarowGetone ( String Where );
# Endregion
# Region No transaction
/// <Summary>
/// Getrecordscount: obtain the total number of records that meet the where condition in the target table.
/// </Summary>
Int Getrecordscount ( String Where );
/// <Summary>
///Newrow returns a datarow that is exactly the same as the outline of the target table.
/// </Summary>
DatarowNewrow ();
/// <Summary>
/// Getemptytable obtains an empty datatable, which reflects the structure of the target table.
/// </Summary>
/// <Returns> </returns>
DatatableGetemptytable ();
# Endregion
}
Go to: datarabbit lightweight data access framework-Sequence