Skip to content

Commit

Permalink
use await on using
Browse files Browse the repository at this point in the history
  • Loading branch information
AmirShitrit committed Mar 20, 2024
1 parent 2dcfd5d commit a5a81d1
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/Proto.Persistence.SqlServer/SqlServerProvider.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Data;
using System.Data.SqlClient;
using System.Threading.Tasks;
using Microsoft.Data.SqlClient;
using Newtonsoft.Json;
using static System.Data.SqlDbType;

Expand Down Expand Up @@ -55,8 +55,7 @@ public SqlServerProvider(
_sqlDeleteSnapshots =
$@"DELETE FROM [{_tableSchema}].[{_tableSnapshots}] WHERE ActorName = @ActorName AND SnapshotIndex <= @SnapshotIndex";

_sqlReadEvents =
$@"SELECT EventIndex, EventData FROM [{_tableSchema}].[{_tableEvents}] WHERE ActorName = @ActorName AND EventIndex >= @IndexStart AND EventIndex <= @IndexEnd ORDER BY EventIndex ASC";
_sqlReadEvents = $@"SELECT EventIndex, EventData FROM [{_tableSchema}].[{_tableEvents}] WHERE ActorName = @ActorName AND EventIndex >= @IndexStart AND EventIndex <= @IndexEnd ORDER BY EventIndex ASC";

_sqlReadSnapshot =
$@"SELECT TOP 1 SnapshotIndex, SnapshotData FROM [{_tableSchema}].[{_tableSnapshots}] WHERE ActorName = @ActorName ORDER BY SnapshotIndex DESC";
Expand Down Expand Up @@ -84,9 +83,9 @@ public Task DeleteSnapshotsAsync(string actorName, long inclusiveToIndex) =>

public async Task<long> GetEventsAsync(string actorName, long indexStart, long indexEnd, Action<object> callback)
{
using var connection = new SqlConnection(_connectionString);
await using var connection = new SqlConnection(_connectionString);

using var command = new SqlCommand(_sqlReadEvents, connection);
await using var command = new SqlCommand(_sqlReadEvents, connection);

await connection.OpenAsync().ConfigureAwait(false);

Expand Down

0 comments on commit a5a81d1

Please sign in to comment.