Basesqlmapdao: idao

Source: Internet
Author: User

Using system;
Using system. collections;
Using system. Collections. Generic;
Using ibatisnet. Common. pagination;
Using ibatisnet. dataaccess;
Using ibatisnet. dataaccess. daosessionhandlers;
Using ibatisnet. dataaccess. exceptions;
Using ibatisnet. dataaccess. interfaces;
Using ibatisnet. datamapper;

Namespace frameworkdemo. Data. mapperdao
{
Public class basesqlmapdao: idao
{
Protected isqlmapper getlocalsqlmap ()
{
Daomanager = daomanager. getinstance (this );
Sqlmapdaosession = (sqlmapdaosession) daomanager. localdaosession;

Return sqlmapdaosession. sqlmap;
}

Protected ilist executequeryforlist (string statementname, object parameterobject)
{
Isqlmapper sqlmap = getlocalsqlmap ();
Try
{
Return sqlmap. queryforlist (statementname, parameterobject );
}
Catch (exception E)
{
Throw new dataaccessexception ("error executing query'" + statementname + "'For list. Cause:" + E. Message, e );
}
}

Protected ilist executequeryforlist (string statementname, object parameterobject, int skipresults, int maxresults)
{
Isqlmapper sqlmap = getlocalsqlmap ();
Try
{
Return sqlmap. queryforlist (statementname, parameterobject, skipresults, maxresults );
}
Catch (exception E)
{
Throw new dataaccessexception ("error executing query'" + statementname + "'For list. Cause:" + E. Message, e );
}
}

Protected ipaginatedlist executequeryforpaginatedlist (string statementname, object parameterobject, int pagesize)
{
Isqlmapper sqlmap = getlocalsqlmap ();
Try
{
Return sqlmap. queryforpaginatedlist (statementname, parameterobject, pagesize );
}
Catch (exception E)
{
Throw new dataaccessexception ("error executing query'" + statementname + "'For paginated list. Cause:" + E. Message, e );
}
}

Protected object executequeryforobject (string statementname, object parameterobject)
{
Isqlmapper sqlmap = getlocalsqlmap ();

Try
{
Return sqlmap. queryforobject (statementname, parameterobject );
}
Catch (exception E)
{
Throw new dataaccessexception ("error executing query'" + statementname + "'for object. Cause:" + E. Message, e );
}
}
Protected object executequeryforobject (string statementname, object parameterobject, object resultobject)
{
Isqlmapper sqlmap = getlocalsqlmap ();

Try
{
Return sqlmap. queryforobject (statementname, parameterobject, resultobject );
}
Catch (exception E)
{
Throw new dataaccessexception ("error executing query'" + statementname + "'for object. Cause:" + E. Message, e );
}
}
Protected ilist <t> executequeryforlist <t> (string statementname, object parameterobject)
{
Isqlmapper sqlmap = getlocalsqlmap ();
Try
{
Return sqlmap. queryforlist <t> (statementname, parameterobject );
}
Catch (exception E)
{
Throw new dataaccessexception ("error executing query'" + statementname + "'For list. Cause:" + E. Message, e );
}
}

Protected ilist <t> executequeryforlist <t> (string statementname, object parameterobject, int skipresults, int maxresults)
{
Isqlmapper sqlmap = getlocalsqlmap ();
Try
{
Return sqlmap. queryforlist <t> (statementname, parameterobject, skipresults, maxresults );
}
Catch (exception E)
{
Throw new dataaccessexception ("error executing query'" + statementname + "'For list. Cause:" + E. Message, e );
}
}

Protected t executequeryforobject <t> (string statementname, object parameterobject)
{
Isqlmapper sqlmap = getlocalsqlmap ();

Try
{
Return sqlmap. queryforobject <t> (statementname, parameterobject );
}
Catch (exception E)
{
Throw new dataaccessexception ("error executing query'" + statementname + "'for object. Cause:" + E. Message, e );
}
}
Protected t executequeryforobject <t> (string statementname, object parameterobject, t resultobject)
{
Isqlmapper sqlmap = getlocalsqlmap ();

Try
{
Return sqlmap. queryforobject <t> (statementname, parameterobject, resultobject );
}
Catch (exception E)
{
Throw new dataaccessexception ("error executing query'" + statementname + "'for object. Cause:" + E. Message, e );
}
}
Protected object executeinsert (string statementname, object parameterobject)
{
Isqlmapper sqlmap = getlocalsqlmap ();

Try
{
Return sqlmap. insert (statementname, parameterobject );
}
Catch (exception E)
{
Throw new dataaccessexception ("error executing query'" + statementname + "'For insert. Cause:" + E. Message, e );
}
}

Protected int executeupdate (string statementname, object parameterobject)
{
Isqlmapper sqlmap = getlocalsqlmap ();

Try
{
Return sqlmap. Update (statementname, parameterobject );
}
Catch (exception E)
{
Throw new dataaccessexception ("error executing query'" + statementname + "'for update. Cause:" + E. Message, e );
}
}

Protected object executedelete (string statementname, object parameterobject)
{
Isqlmapper sqlmap = getlocalsqlmap ();

Try
{
Return sqlmap. Delete (statementname, parameterobject );
}
Catch (exception E)
{
Throw new dataaccessexception ("error executing query'" + statementname + "'For Delete. Cause:" + E. Message, e );
}
}
}
}

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.