Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mssqlprovider improvements #2108

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Proto.Persistence\Proto.Persistence.csproj" />
Expand Down
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
Loading