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

Make the saga persistence compatible with MongoDB.Driver Version 2.19 and higher #482

Merged
merged 2 commits into from
Mar 28, 2023
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 @@ -13,7 +13,7 @@
<PackageReference Include="GitHubActionsTestLogger" Version="2.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<!-- DO NOT REMOVE MongoDB.Driver, it is added so that dependabot knows about version changes-->
<PackageReference Include="MongoDB.Driver" Version="2.18.0" />
<PackageReference Include="MongoDB.Driver" Version="2.19.0" />
<PackageReference Include="NServiceBus" Version="8.0.3" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MongoDB.Driver" Version="[2.17.1, 3.0.0)" />
<PackageReference Include="MongoDB.Driver" Version="[2.19.0, 3.0.0)" />
<PackageReference Include="NServiceBus" Version="[8.0.0, 9.0.0)" />
<PackageReference Include="Particular.Packaging" Version="2.3.0" PrivateAssets="All" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/NServiceBus.Storage.MongoDB/Sagas/SagaPersister.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public async Task Save(IContainSagaData sagaData, SagaCorrelationProperty correl
var storageSession = ((SynchronizedStorageSession)session).Session;
var sagaDataType = sagaData.GetType();

var document = sagaData.ToBsonDocument();
var document = sagaData.ToBsonDocument(sagaDataType);
document.Add(versionElementName, 0);

await storageSession.InsertOneAsync(sagaDataType, document, cancellationToken).ConfigureAwait(false);
Expand All @@ -34,7 +34,7 @@ public async Task Update(IContainSagaData sagaData, ISynchronizedStorageSession
var sagaDataType = sagaData.GetType();

var version = storageSession.RetrieveVersion(sagaDataType);
var document = sagaData.ToBsonDocument().SetElement(new BsonElement(versionElementName, version + 1));
var document = sagaData.ToBsonDocument(sagaDataType).SetElement(new BsonElement(versionElementName, version + 1));

var result = await storageSession.ReplaceOneAsync(sagaDataType, filterBuilder.Eq(idElementName, sagaData.Id) & filterBuilder.Eq(versionElementName, version), document, cancellationToken).ConfigureAwait(false);

Expand Down