Beispiel #1
0
        private static void SqlSugarHelper_SqlExceptionHandler(SqlSugarException obj)
        {
            string strParam = "";

            if (obj.Parametres != null)
            {
                var arr = obj.Parametres as SugarParameter[];
                if (arr != null)
                {
                    strParam = arr.ConcatElement(Environment.NewLine, x => string.Format("{0}: {1}", x.ParameterName, x.Value.ToString()));
                }
            }

            string str = "";

            str += Environment.NewLine + obj.Sql;
            if (!string.IsNullOrEmpty(strParam))
            {
                str += Environment.NewLine + strParam;
            }
            if (!string.IsNullOrEmpty(obj.StackTrace))
            {
                str += Environment.NewLine + obj.StackTrace;
            }

            ConsoleHelper.WriteLine(
                ELogCategory.Sql,
                string.Format("Execute SQL Exception: {0}{1}", obj.Message, str),
                true
                );
        }
Beispiel #2
0
 private void OnError(SqlSugarException exp)
 {
     try
     {
         //exp.sql exp.parameters 可以拿到参数和错误Sql
         Log.WriteDebugLine(
             $"SQL OnError:{exp.Sql},{exp.Parametres},{exp.InnerException?.Message},{exp.InnerException?.StackTrace}");
     }
     catch (Exception ex)
     {
         Log.WriteErrorLine($"Sql Error:{exp.Sql} {ex.Message} {ex.StackTrace}");
     }
 }