forked from ThatRendle/Simple.Data
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTraceHelper.cs
More file actions
40 lines (37 loc) · 1.11 KB
/
TraceHelper.cs
File metadata and controls
40 lines (37 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Diagnostics;
using System.Linq;
using System.Text;
namespace Simple.Data.Ado
{
using System.Security;
public static class TraceHelper
{
public static void WriteTrace(this IDbCommand command)
{
if (Database.TraceLevel < TraceLevel.Info) return;
try
{
var str = new StringBuilder();
str.AppendLine();
str.AppendLine(command.CommandType.ToString());
str.AppendLine(command.CommandText);
foreach (var parameter in command.Parameters.OfType<DbParameter>())
{
str.AppendFormat("{0} ({1}) = {2}", parameter.ParameterName, parameter.DbType, parameter.Value);
str.AppendLine();
}
Trace.WriteLine(str.ToString(), "Simple.Data.Ado");
}
catch (Exception)
{
#if(DEBUG)
throw;
#endif
}
}
}
}