This is what your .NET code could look if you were to rewrite the whole thing into stored procedures:
public List<User> listUsers(Guid pPersonTypeId, string pFirstName, string pLastName)
{
List<User> list = new List<User>();
List<SqlParameter> pa = new List<SqlParameter>();
pa.Add(SqlHelper.createSqlParameter("@ID_PERSONTYPE", SqlDbType.UniqueIdentifier, pPersonTypeId != Guid.Empty ? (Guid?)pPersonTypeId : null));
pa.Add(SqlHelper.createSqlParameter("@FNAME", SqlDbType.NVarChar, String.IsNullOrEmpty(pFirstName) ? null : pFirstName));
pa.Add(SqlHelper.createSqlParameter("@LNAME", SqlDbType.NVarChar, String.IsNullOrEmpty(pLastName) ? null : pLastName));
try
{
DataSet ds = SqlHelper.ExecuteDataset("proc_USER_list", pa.ToArray());
if (ds.Tables.Count == 0)
return list;
foreach (DataRow r in ds.Tables[0].Rows)
{
User u = new User();
//populate your User object with data from the DataRow
...
list.Add(u);
}
return list;
}
catch (Exception ex)
{
throw (new BaseException(ex));
}
}
You would of course need to implement the SQLHelper and SQLParameter classes, which is fairly simple.
if this is not a way you want to go right now, I suggest something like creating an XML document (one per data access class), storing your queries in it, and writing a very simple wrapper class to fetch your queries based on a query code or ID. The XML could look like this for example:
<query code="listUsers"> select * from USER where NAME = {0} </query>
To go even further, I guess you could use the method name as a query code and even have the wrapper use reflection to see the method it's being called from and use the name of the method to look for your query in the XML.
Using resource classes to store your queries is even simpler, but I'm not sure there are any benefits at all to be had there, with the XML at least you get SOME separation.