diff --git a/src/OpenSharpTrace.TestApi/OpenSharpTrace.TestApi.csproj b/src/OpenSharpTrace.TestApi/OpenSharpTrace.TestApi.csproj
index 8bae57c..82fc460 100644
--- a/src/OpenSharpTrace.TestApi/OpenSharpTrace.TestApi.csproj
+++ b/src/OpenSharpTrace.TestApi/OpenSharpTrace.TestApi.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/src/OpenSharpTrace/OpenSharpTrace - Backup.csproj b/src/OpenSharpTrace/OpenSharpTrace - Backup.csproj
deleted file mode 100644
index a243417..0000000
--- a/src/OpenSharpTrace/OpenSharpTrace - Backup.csproj
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
- net8.0
- Francesco Del Re
- true
- .NET library to automate trace and observability of REST APIs in microservices environment
- https://github.com/engineering87/OpenSharpTrace
- https://github.com/engineering87/OpenSharpTrace
- LICENSE.txt
- 4.1.0
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- True
-
-
-
-
-
diff --git a/src/OpenSharpTrace/OpenSharpTrace.csproj b/src/OpenSharpTrace/OpenSharpTrace.csproj
index 3947dfb..5c0e609 100644
--- a/src/OpenSharpTrace/OpenSharpTrace.csproj
+++ b/src/OpenSharpTrace/OpenSharpTrace.csproj
@@ -20,14 +20,14 @@
-
-
-
+
+
+
-
-
-
+
+
+
diff --git a/src/OpenSharpTrace/Persistence/SQL/SqlTraceRepository.cs b/src/OpenSharpTrace/Persistence/SQL/SqlTraceRepository.cs
index 1d7f785..b39aa89 100644
--- a/src/OpenSharpTrace/Persistence/SQL/SqlTraceRepository.cs
+++ b/src/OpenSharpTrace/Persistence/SQL/SqlTraceRepository.cs
@@ -17,7 +17,7 @@ public class SqlTraceRepository : ISqlTraceRepository
public SqlTraceRepository(ILoggerFactory loggerFactory, TraceContext context)
{
- _context = context;
+ _context = context ?? throw new ArgumentNullException(nameof(context));
_logger = loggerFactory.CreateLogger(GetType().ToString());
}
@@ -27,6 +27,11 @@ public SqlTraceRepository(ILoggerFactory loggerFactory, TraceContext context)
///
public void InsertMany(List entities)
{
+ if (entities == null || entities.Count == 0)
+ {
+ return;
+ }
+
try
{
var strategy = _context.Database.CreateExecutionStrategy();
diff --git a/src/OpenSharpTrace/Persistence/SQL/TraceContext.cs b/src/OpenSharpTrace/Persistence/SQL/TraceContext.cs
index 29bf04b..1d1f702 100644
--- a/src/OpenSharpTrace/Persistence/SQL/TraceContext.cs
+++ b/src/OpenSharpTrace/Persistence/SQL/TraceContext.cs
@@ -40,7 +40,11 @@ private void EnsureTraceTableExists()
{
try
{
- connection.Open();
+ if (connection.State != System.Data.ConnectionState.Open)
+ {
+ connection.Open();
+ }
+
using (var command = connection.CreateCommand())
{
command.CommandText = @"