Improved data access layer query for Li Tianping Code Generator

Source: Internet
Author: User

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
}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.