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 );
}
}
}
}