コード例 #1
0
 /// <summary>
 /// 执行带返回结果集的存储过程
 /// </summary>
 /// <param name="sql">存储过程名称</param>
 /// <param name="parameters">存储过程参数</param>
 /// <returns>返回结果集</returns>
 public IList <T> ExecuteProcedure <T>(string sql, DataParameters parameters = null)
 {
     try
     {
         return(Connection.Query <T>(sql, parameters?.GetDynamicParameters(), Transaction, true, null, CommandType.StoredProcedure).ToList());
     }
     catch (Exception e)
     {
         Rollback();//异常时候回滚,防止数据库锁死
         throw new DataException(e.Message);
     }
 }
コード例 #2
0
 /// <summary>
 /// 执行无返回参数的存储过程
 /// </summary>
 /// <param name="sql">存储过程名称</param>
 /// <param name="parameters">存储过程参数</param>
 /// <returns>返回结果集(非返回参数)</returns>
 public int ExecuteProcedureNonQuery(string sql, DataParameters parameters = null)
 {
     try
     {
         return(Connection.Execute(sql, parameters?.GetDynamicParameters(), Transaction, null, CommandType.StoredProcedure));
     }
     catch (Exception e)
     {
         Rollback();//异常时候回滚,防止数据库锁死
         throw new DataException(e.Message);
     }
 }
コード例 #3
0
 /// <summary>
 /// 执行带返回参数的存储过程
 /// </summary>
 /// <param name="sql"></param>
 /// <param name="parameters">存储过程参数</param>
 /// <returns>返回值字典集合</returns>
 public IDictionary <string, object> ExecuteProcedure(string sql, DataParameters parameters = null)
 {
     try
     {
         Connection.Execute(sql, parameters?.GetDynamicParameters(), Transaction, null, CommandType.StoredProcedure);
         return(parameters.GetOutput());
     }
     catch (Exception e)
     {
         Rollback();//异常时候回滚,防止数据库锁死
         throw new DataException(e.Message);
     }
 }