/// <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>(ResolveParameters(sql, parameters), parameters?.GetDynamicParameters(), Transaction, true, null, CommandType.StoredProcedure).ToList()); } catch (Exception e) { Rollback();//异常时候回滚,防止数据库锁死 throw new DataException(e.Message); } }
/// <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(ResolveParameters(sql, parameters), parameters?.GetDynamicParameters(), Transaction, null, CommandType.StoredProcedure); return(parameters.GetOutput()); } catch (Exception e) { Rollback();//异常时候回滚,防止数据库锁死 throw new DataException(e.Message); } }