From 6e71ca685d4be837303af2f7d30f443a9e5a3f04 Mon Sep 17 00:00:00 2001 From: Ryan Thomas Date: Thu, 25 Sep 2025 13:50:00 -0500 Subject: [PATCH 1/2] Update snippets references --- Snippets/ABSDataBus/ABSDataBus_7/ABSDataBus_7.csproj | 2 +- Snippets/ASBS/ASBS_3/ASBS_3.csproj | 2 +- Snippets/ASBS/ASBS_4/ASBS_4.csproj | 2 +- Snippets/ASBS/ASBS_5/ASBS_5.csproj | 8 ++++---- Snippets/ASBS/ASBS_6/ASBS_6.csproj | 8 ++++---- Snippets/Bridge/Bridge_5/Bridge_5.csproj | 2 +- Snippets/GatewaySql/GatewaySql_4/GatewaySql_4.csproj | 2 +- Snippets/LearningPersistence/Core_10/Core_10.csproj | 2 +- Snippets/LearningTransport/Core_10/Core_10.csproj | 2 +- .../PostgreSqlTransport_8/PostgreSqlTransport_8.csproj | 2 +- .../PostgreSqlTransport_9/PostgreSqlTransport_9.csproj | 2 +- Snippets/RawMessaging/Core_10/Core_10.csproj | 2 +- Snippets/SystemJson/Core_10/Core_10.csproj | 2 +- Snippets/Xml/Core_10/Core_10.csproj | 2 +- 14 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Snippets/ABSDataBus/ABSDataBus_7/ABSDataBus_7.csproj b/Snippets/ABSDataBus/ABSDataBus_7/ABSDataBus_7.csproj index 033b82402ad..8d619f17970 100644 --- a/Snippets/ABSDataBus/ABSDataBus_7/ABSDataBus_7.csproj +++ b/Snippets/ABSDataBus/ABSDataBus_7/ABSDataBus_7.csproj @@ -6,7 +6,7 @@ - + diff --git a/Snippets/ASBS/ASBS_3/ASBS_3.csproj b/Snippets/ASBS/ASBS_3/ASBS_3.csproj index 3e2c7378673..7490ac8b29c 100644 --- a/Snippets/ASBS/ASBS_3/ASBS_3.csproj +++ b/Snippets/ASBS/ASBS_3/ASBS_3.csproj @@ -3,7 +3,7 @@ net48 - + \ No newline at end of file diff --git a/Snippets/ASBS/ASBS_4/ASBS_4.csproj b/Snippets/ASBS/ASBS_4/ASBS_4.csproj index 9d19cd3c9d8..4ac5d824bf0 100644 --- a/Snippets/ASBS/ASBS_4/ASBS_4.csproj +++ b/Snippets/ASBS/ASBS_4/ASBS_4.csproj @@ -3,7 +3,7 @@ net8.0 - + \ No newline at end of file diff --git a/Snippets/ASBS/ASBS_5/ASBS_5.csproj b/Snippets/ASBS/ASBS_5/ASBS_5.csproj index a7a3cefb32e..13fe1ef90f2 100644 --- a/Snippets/ASBS/ASBS_5/ASBS_5.csproj +++ b/Snippets/ASBS/ASBS_5/ASBS_5.csproj @@ -3,10 +3,10 @@ net8.0 - - + + - - + + \ No newline at end of file diff --git a/Snippets/ASBS/ASBS_6/ASBS_6.csproj b/Snippets/ASBS/ASBS_6/ASBS_6.csproj index a1e1b6c3416..1ef36972123 100644 --- a/Snippets/ASBS/ASBS_6/ASBS_6.csproj +++ b/Snippets/ASBS/ASBS_6/ASBS_6.csproj @@ -3,10 +3,10 @@ net10.0 - - + + - - + + \ No newline at end of file diff --git a/Snippets/Bridge/Bridge_5/Bridge_5.csproj b/Snippets/Bridge/Bridge_5/Bridge_5.csproj index 71341786dea..0bd196760d7 100644 --- a/Snippets/Bridge/Bridge_5/Bridge_5.csproj +++ b/Snippets/Bridge/Bridge_5/Bridge_5.csproj @@ -5,6 +5,6 @@ - + \ No newline at end of file diff --git a/Snippets/GatewaySql/GatewaySql_4/GatewaySql_4.csproj b/Snippets/GatewaySql/GatewaySql_4/GatewaySql_4.csproj index 3f5d3c58fba..817bbd63f1f 100644 --- a/Snippets/GatewaySql/GatewaySql_4/GatewaySql_4.csproj +++ b/Snippets/GatewaySql/GatewaySql_4/GatewaySql_4.csproj @@ -4,6 +4,6 @@ - + \ No newline at end of file diff --git a/Snippets/LearningPersistence/Core_10/Core_10.csproj b/Snippets/LearningPersistence/Core_10/Core_10.csproj index 165b5ca936d..99f2096541e 100644 --- a/Snippets/LearningPersistence/Core_10/Core_10.csproj +++ b/Snippets/LearningPersistence/Core_10/Core_10.csproj @@ -3,6 +3,6 @@ net10.0 - + \ No newline at end of file diff --git a/Snippets/LearningTransport/Core_10/Core_10.csproj b/Snippets/LearningTransport/Core_10/Core_10.csproj index 165b5ca936d..99f2096541e 100644 --- a/Snippets/LearningTransport/Core_10/Core_10.csproj +++ b/Snippets/LearningTransport/Core_10/Core_10.csproj @@ -3,6 +3,6 @@ net10.0 - + \ No newline at end of file diff --git a/Snippets/PostgreSqlTransport/PostgreSqlTransport_8/PostgreSqlTransport_8.csproj b/Snippets/PostgreSqlTransport/PostgreSqlTransport_8/PostgreSqlTransport_8.csproj index cd65d5d98b7..ec976603e1b 100644 --- a/Snippets/PostgreSqlTransport/PostgreSqlTransport_8/PostgreSqlTransport_8.csproj +++ b/Snippets/PostgreSqlTransport/PostgreSqlTransport_8/PostgreSqlTransport_8.csproj @@ -5,7 +5,7 @@ - + diff --git a/Snippets/PostgreSqlTransport/PostgreSqlTransport_9/PostgreSqlTransport_9.csproj b/Snippets/PostgreSqlTransport/PostgreSqlTransport_9/PostgreSqlTransport_9.csproj index c8d70c31eb9..cc5729f876a 100644 --- a/Snippets/PostgreSqlTransport/PostgreSqlTransport_9/PostgreSqlTransport_9.csproj +++ b/Snippets/PostgreSqlTransport/PostgreSqlTransport_9/PostgreSqlTransport_9.csproj @@ -5,7 +5,7 @@ - + diff --git a/Snippets/RawMessaging/Core_10/Core_10.csproj b/Snippets/RawMessaging/Core_10/Core_10.csproj index 165b5ca936d..99f2096541e 100644 --- a/Snippets/RawMessaging/Core_10/Core_10.csproj +++ b/Snippets/RawMessaging/Core_10/Core_10.csproj @@ -3,6 +3,6 @@ net10.0 - + \ No newline at end of file diff --git a/Snippets/SystemJson/Core_10/Core_10.csproj b/Snippets/SystemJson/Core_10/Core_10.csproj index 0510952e8aa..732ae69bf47 100644 --- a/Snippets/SystemJson/Core_10/Core_10.csproj +++ b/Snippets/SystemJson/Core_10/Core_10.csproj @@ -3,6 +3,6 @@ net10.0 - + \ No newline at end of file diff --git a/Snippets/Xml/Core_10/Core_10.csproj b/Snippets/Xml/Core_10/Core_10.csproj index 5cf99f44b4c..5c8edd90199 100644 --- a/Snippets/Xml/Core_10/Core_10.csproj +++ b/Snippets/Xml/Core_10/Core_10.csproj @@ -6,7 +6,7 @@ - + \ No newline at end of file From 5faa32f3d9210bfc77389eeb249d3a814038fd80 Mon Sep 17 00:00:00 2001 From: Ryan Thomas Date: Thu, 25 Sep 2025 13:50:36 -0500 Subject: [PATCH 2/2] Fix v6 and add v7 for TransactionalSession.MongoDB snippets --- .../TransactionalSession.MongoDB/MongoTS.sln | 18 ++++++- .../MongoTS_6/MongoTS_6.csproj | 4 +- .../MongoTS_7/MongoDBConfig.cs | 48 +++++++++++++++++++ .../MongoTS_7/MongoTS_7.csproj | 8 ++++ .../MongoTS_7/MyMessage.cs | 5 ++ .../{MongoTS_6 => MongoTS_7}/prerelease.txt | 0 6 files changed, 79 insertions(+), 4 deletions(-) create mode 100644 Snippets/TransactionalSession.MongoDB/MongoTS_7/MongoDBConfig.cs create mode 100644 Snippets/TransactionalSession.MongoDB/MongoTS_7/MongoTS_7.csproj create mode 100644 Snippets/TransactionalSession.MongoDB/MongoTS_7/MyMessage.cs rename Snippets/TransactionalSession.MongoDB/{MongoTS_6 => MongoTS_7}/prerelease.txt (100%) diff --git a/Snippets/TransactionalSession.MongoDB/MongoTS.sln b/Snippets/TransactionalSession.MongoDB/MongoTS.sln index f6c736d1028..eec8d26a091 100644 --- a/Snippets/TransactionalSession.MongoDB/MongoTS.sln +++ b/Snippets/TransactionalSession.MongoDB/MongoTS.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.2.32602.215 +# Visual Studio Version 18 +VisualStudioVersion = 18.0.11018.127 d18.0 MinimumVisualStudioVersion = 15.0.26730.12 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MongoTS_2", "MongoTS_2\MongoTS_2.csproj", "{34E49F9B-04E5-45AF-9009-2A5B88B9203B}" EndProject @@ -12,6 +12,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoTS_5", "MongoTS_5\Mong EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoTS_6", "MongoTS_6\MongoTS_6.csproj", "{1C1812F8-F58A-48A0-9A48-0EC7902741F1}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MongoTS_7", "MongoTS_7\MongoTS_7.csproj", "{01E7FD88-AF42-FA16-18A9-7ABF80AEC1AF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -82,6 +84,18 @@ Global {1C1812F8-F58A-48A0-9A48-0EC7902741F1}.Release|x64.Build.0 = Release|Any CPU {1C1812F8-F58A-48A0-9A48-0EC7902741F1}.Release|x86.ActiveCfg = Release|Any CPU {1C1812F8-F58A-48A0-9A48-0EC7902741F1}.Release|x86.Build.0 = Release|Any CPU + {01E7FD88-AF42-FA16-18A9-7ABF80AEC1AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {01E7FD88-AF42-FA16-18A9-7ABF80AEC1AF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {01E7FD88-AF42-FA16-18A9-7ABF80AEC1AF}.Debug|x64.ActiveCfg = Debug|Any CPU + {01E7FD88-AF42-FA16-18A9-7ABF80AEC1AF}.Debug|x64.Build.0 = Debug|Any CPU + {01E7FD88-AF42-FA16-18A9-7ABF80AEC1AF}.Debug|x86.ActiveCfg = Debug|Any CPU + {01E7FD88-AF42-FA16-18A9-7ABF80AEC1AF}.Debug|x86.Build.0 = Debug|Any CPU + {01E7FD88-AF42-FA16-18A9-7ABF80AEC1AF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {01E7FD88-AF42-FA16-18A9-7ABF80AEC1AF}.Release|Any CPU.Build.0 = Release|Any CPU + {01E7FD88-AF42-FA16-18A9-7ABF80AEC1AF}.Release|x64.ActiveCfg = Release|Any CPU + {01E7FD88-AF42-FA16-18A9-7ABF80AEC1AF}.Release|x64.Build.0 = Release|Any CPU + {01E7FD88-AF42-FA16-18A9-7ABF80AEC1AF}.Release|x86.ActiveCfg = Release|Any CPU + {01E7FD88-AF42-FA16-18A9-7ABF80AEC1AF}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Snippets/TransactionalSession.MongoDB/MongoTS_6/MongoTS_6.csproj b/Snippets/TransactionalSession.MongoDB/MongoTS_6/MongoTS_6.csproj index 8b7f1d06167..de7fa6aa9c9 100644 --- a/Snippets/TransactionalSession.MongoDB/MongoTS_6/MongoTS_6.csproj +++ b/Snippets/TransactionalSession.MongoDB/MongoTS_6/MongoTS_6.csproj @@ -1,8 +1,8 @@ - net10.0 + net8.0 - + \ No newline at end of file diff --git a/Snippets/TransactionalSession.MongoDB/MongoTS_7/MongoDBConfig.cs b/Snippets/TransactionalSession.MongoDB/MongoTS_7/MongoDBConfig.cs new file mode 100644 index 00000000000..0bc34bce8f5 --- /dev/null +++ b/Snippets/TransactionalSession.MongoDB/MongoTS_7/MongoDBConfig.cs @@ -0,0 +1,48 @@ +using Microsoft.Extensions.DependencyInjection; +using NServiceBus; +using NServiceBus.TransactionalSession; +using System; +using System.Threading.Tasks; + +public class MongoDBConfig +{ + public void Configure(EndpointConfiguration config) + { + #region enabling-transactional-session-mongo + + var persistence = config.UsePersistence(); + persistence.EnableTransactionalSession(); + + #endregion + } + + public async Task OpenDefault(IServiceProvider serviceProvider) + { + #region open-transactional-session-mongo + + using var childScope = serviceProvider.CreateScope(); + var session = childScope.ServiceProvider.GetService(); + await session.Open(); + + // use the session + + await session.Commit(); + + #endregion + } + + public async Task UseSession(ITransactionalSession session) + { + #region use-transactional-session-mongo + await session.Open(); + + // add messages to the transaction: + await session.Send(new MyMessage()); + + // access the database: + var mongoSession = session.SynchronizedStorageSession.MongoPersistenceSession(); + + await session.Commit(); + #endregion + } +} diff --git a/Snippets/TransactionalSession.MongoDB/MongoTS_7/MongoTS_7.csproj b/Snippets/TransactionalSession.MongoDB/MongoTS_7/MongoTS_7.csproj new file mode 100644 index 00000000000..c0d679e84ac --- /dev/null +++ b/Snippets/TransactionalSession.MongoDB/MongoTS_7/MongoTS_7.csproj @@ -0,0 +1,8 @@ + + + net10.0 + + + + + \ No newline at end of file diff --git a/Snippets/TransactionalSession.MongoDB/MongoTS_7/MyMessage.cs b/Snippets/TransactionalSession.MongoDB/MongoTS_7/MyMessage.cs new file mode 100644 index 00000000000..9f2b1c52e6d --- /dev/null +++ b/Snippets/TransactionalSession.MongoDB/MongoTS_7/MyMessage.cs @@ -0,0 +1,5 @@ +using NServiceBus; + +public class MyMessage : ICommand +{ +} \ No newline at end of file diff --git a/Snippets/TransactionalSession.MongoDB/MongoTS_6/prerelease.txt b/Snippets/TransactionalSession.MongoDB/MongoTS_7/prerelease.txt similarity index 100% rename from Snippets/TransactionalSession.MongoDB/MongoTS_6/prerelease.txt rename to Snippets/TransactionalSession.MongoDB/MongoTS_7/prerelease.txt