/// <summary> SQL异常记录写入~/App_Data/SqlExceptionLog.xml </summary> /// <param name="cmdType">执行方式</param> /// <param name="sql">T-SQL</param> /// <param name="param">SQL参数</param> /// <param name="ex">异常信息</param> public static void Write(Exception ex, CommandType cmdType, string sql, List<DbParameter> param) { var entity = new SqlExceptionLogEntity { ex = ex, Message = ex.Message.Replace("\r\n", ""), CmdType = cmdType, SqlParamList = new List<SqlParam>(), Sql = sql, }; if (param != null && param.Count > 0) { param.ForEach(o => entity.SqlParamList.Add(new SqlParam { Name = o.ParameterName, Value = (o.Value ?? "null").ToString() })); } entity.Write(); }
/// <summary> SQL异常记录写入~/App_Data/SqlExceptionLog.xml </summary> /// <param name="cmdType">执行方式</param> /// <param name="sql">T-SQL</param> /// <param name="param">SQL参数</param> /// <param name="ex">异常信息</param> public static void Write(Exception ex, CommandType cmdType, string sql, List <DbParameter> param) { var entity = new SqlExceptionLogEntity { ex = ex, Message = ex.Message.Replace("\r\n", ""), CmdType = cmdType, SqlParamList = new List <SqlParam>(), Sql = sql, }; if (param != null && param.Count > 0) { param.ForEach(o => entity.SqlParamList.Add(new SqlParam { Name = o.ParameterName, Value = (o.Value ?? "null").ToString() })); } entity.Write(); }