Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 0e9cfe2

Browse files
committed
refactor GetDebugString() from DebugCommand
1 parent 5ec52ee commit 0e9cfe2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/ServiceStack.OrmLite/OrmLiteUtils.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ public static void HandleException(Exception ex, string message = null)
5454
}
5555

5656
public static void DebugCommand(this ILog log, IDbCommand cmd)
57+
{
58+
log.Debug(GetDebugString(cmd));
59+
}
60+
61+
public static string GetDebugString(this IDbCommand cmd)
5762
{
5863
var sb = StringBuilderCache.Allocate();
5964

@@ -62,18 +67,19 @@ public static void DebugCommand(this ILog log, IDbCommand cmd)
6267
if (cmd.Parameters.Count > 0)
6368
{
6469
sb.AppendLine()
65-
.Append("PARAMS: ");
70+
.Append("PARAMS: ");
6671

6772
for (var i = 0; i < cmd.Parameters.Count; i++)
6873
{
69-
var p = (IDataParameter)cmd.Parameters[i];
74+
var p = (IDataParameter) cmd.Parameters[i];
7075
if (i > 0)
7176
sb.Append(", ");
7277
sb.Append($"{p.ParameterName}={p.Value}");
7378
}
7479
}
7580

76-
log.Debug(StringBuilderCache.ReturnAndFree(sb));
81+
var dbAndParams = StringBuilderCache.ReturnAndFree(sb);
82+
return dbAndParams;
7783
}
7884

7985
public static T CreateInstance<T>()

0 commit comments

Comments
 (0)