For code generators, complex queries do not provide methods in the data access layer and transactions. Therefore, for actual project applications, I have developed a new data access interface in the framework of Li Tianping.
The IDAL interface is as follows:
IBaseDataHelper
/// <Summary>
/// The public data interface is mainly used for queries, transactions, and other complex data operations.
/// </Summary>
Public interface IBaseDataHelper
{
/// <Summary>
/// Return DataSet using SQL statements
/// </Summary>
/// <Param name = "strSql"> input SQL statement </param>
/// <Returns> </returns>
DataSet BaseQuery (string strSql );
/// <Summary>
/// SQL statement execution
/// </Summary>
/// <Param name = "strSql"> input SQL statement </param>
/// <Returns> Number of affected rows </returns>
Int ExecuteSql (string strSql );
/// <Summary>
/// Execute the transaction
/// </Summary>
/// <Param name = "SQLStringList"> input SQL statement array </param>
/// <Returns> Successful </returns>
Bool ExecuteSqlTran (ArrayList SQLStringList );
/// <Summary>
/// Execute the transaction
/// </Summary>
/// <Param name = "SQLStringList"> input SQL statement HashTable </param>
/// <Returns> Successful </returns>
Bool ExecuteSqlTran (Hashtable SQLStringList );
/// <Summary>
/// Obtain a single data using an SQL statement
/// </Summary>
/// <Param name = "strSql"> input SQL statement </param>
/// <Returns> Data Object </returns>
Object GetSingle (string strSql );
}
The OracelDAL implementation code is as follows:
Public class BaseDataHelper: IBaseDataHelper
{
# Region IBaseDataHelper Member
Public System. Data. DataSet BaseQuery (string strSql)
{
Try
{
Return DbHelperOra. Query (strSql );
}
Catch (System. Data. OracleClient. OracleException ex)
{
Throw new Exception (ex. Message );
}
}
# Endregion
# Region IBaseDataHelper Member
Public int ExecuteSql (string strSql)
{
Try
{
Return DbHelperOra. ExecuteSql (strSql );
}
Catch (System. Data. OracleClient. OracleException ex)
{
Throw new Exception (ex. Message );
}
}
Public bool ExecuteSqlTran (ArrayList SQLStringList)
{
Try
{
DbHelperOra. ExecuteSqlTran (SQLStringList );
}
Catch (System. Exception e)
{
Throw new Exception (e. Message );
}
Return true;
}
Public bool ExecuteSqlTran (Hashtable SQLStringList)
{
Try
{
DbHelperOra. ExecuteSqlTran (SQLStringList );
}
Catch (System. Exception e)
{
Throw new Exception (e. Message );
}
Return true;
}
# Endregion
# Region IBaseDataHelper Member
Public object GetSingle (string strSql)
{
Try
{
Return DbHelperOra. GetSingle (strSql );
}
Catch (System. Data. OracleClient. OracleException ex)
{
Throw new Exception (ex. Message );
}
}
# Endregion
}