Skip to content

Commit

Permalink
Switch to Microsoft.Data.SqlClient for database operations (#99)
Browse files Browse the repository at this point in the history
- Updated ClientAbortMiddleware to handle Microsoft.Data.SqlClient.SqlException.
- Added Microsoft.Data.SqlClient package reference to TournamentCalendar.csproj.
- Changed database provider factory in WebAppStartup to Microsoft.Data.SqlClient.SqlClientFactory.
  • Loading branch information
axunonb authored Jan 4, 2025
1 parent 5f0134d commit 88007da
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Src/TournamentCalendar/Middleware/ClientAbortMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public async Task InvokeAsync(HttpContext context, RequestDelegate next)
// If the cancellation token has not been requested,
// it means that the exception was caused by the client closing the connection.
// Note: SqlException with message "Operation cancelled by user may throw, too, but rarely.
catch (Exception ex) when (ex is TaskCanceledException or SqlException && context.RequestAborted.IsCancellationRequested)
catch (Exception ex) when (ex is TaskCanceledException or Microsoft.Data.SqlClient.SqlException && context.RequestAborted.IsCancellationRequested)
{
// Log the exception and stop the request queue.
_logger.LogWarning("Request aborted by client: '{exception}'. Processing stops.", ex.GetType().ToString());
Expand Down
1 change: 1 addition & 0 deletions Src/TournamentCalendar/TournamentCalendar.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<PackageReference Include="cloudscribe.Web.Navigation" Version="8.0.0" />
<PackageReference Include="JSNLog" Version="3.0.3" />
<PackageReference Include="MailMergeLib" Version="5.12.3" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" />
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="3.1.6" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
Expand Down
6 changes: 3 additions & 3 deletions Src/TournamentCalendar/WebAppStartup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,13 @@ private static void ConfigureLlblgenPro(Data.IDbContext dbContext, IWebHostEnvir
{
RuntimeConfiguration.ConfigureDQE<SD.LLBLGen.Pro.DQE.SqlServer.SQLServerDQEConfiguration>(c => c
.SetTraceLevel(TraceLevel.Off)
.AddDbProviderFactory(typeof(System.Data.SqlClient.SqlClientFactory)));
.AddDbProviderFactory(typeof(Microsoft.Data.SqlClient.SqlClientFactory)));
}
else
{
RuntimeConfiguration.ConfigureDQE<SD.LLBLGen.Pro.DQE.SqlServer.SQLServerDQEConfiguration>(c => c
RuntimeConfiguration.ConfigureDQE<SD.LLBLGen.Pro.DQE.SqlServer.SQLServerDQEConfiguration>(static c => c
.SetTraceLevel(TraceLevel.Verbose)
.AddDbProviderFactory(typeof(System.Data.SqlClient.SqlClientFactory)));
.AddDbProviderFactory(typeof(Microsoft.Data.SqlClient.SqlClientFactory)));

RuntimeConfiguration.Tracing.SetTraceLevel("ORMPersistenceExecution", TraceLevel.Verbose);
RuntimeConfiguration.Tracing.SetTraceLevel("ORMPlainSQLQueryExecution", TraceLevel.Verbose);
Expand Down

0 comments on commit 88007da

Please sign in to comment.