Hi all,
I'm trying to code a method that could execute any (or almost) HQL query, but I'm not really advanced in C#. :(
that would give something like that:
Code:
public void Delete(string query, object[] parameters, object[] values)
{
ITransaction tx = null;
try
{
//query = "from table name where columnName1 = :columnValue1 , columnName2 = :columnValue2 , ..."
//here loop through the array and produce a string formated as follow:
//stringparameternames = "parameter1 " + "," + "parameter2 " + "," ...
//same here for their values:
//stringparametervalues = "value1 " + "," + "value2 " + "," ...
tx = _session.BeginTransaction();
_session.Delete(query, stringparameternames, stringparametervalues);
tx.Commit();
}
catch (Exception ex)
{
if (tx!=null) tx.Rollback();
throw;
}
}
Would that work and would that be "safe"?
Other then that, is it possible to safely make that even more flexible?
Thx a lot for your attention, advices and help.
Pierre