From bb9070098dcc5b76d9eaf2be7e207e43a8a41d97 Mon Sep 17 00:00:00 2001 From: Lombiq Date: Wed, 19 Mar 2014 01:31:20 +0100 Subject: [PATCH] #20539: Using reliable transactions when on SQL Azure Work Item: 20539 --- .../Data/Providers/SqlServerDataServicesProvider.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Orchard/Data/Providers/SqlServerDataServicesProvider.cs b/src/Orchard/Data/Providers/SqlServerDataServicesProvider.cs index c7dbd6b61..139dea186 100644 --- a/src/Orchard/Data/Providers/SqlServerDataServicesProvider.cs +++ b/src/Orchard/Data/Providers/SqlServerDataServicesProvider.cs @@ -27,7 +27,7 @@ namespace Orchard.Data.Providers { persistence = persistence.ConnectionString(_connectionString); // when using Sql Server Azure, use a specific driver, c.f. https://orchard.codeplex.com/workitem/19315 - if (_connectionString.ToLowerInvariant().Contains("database.windows.net")) { + if (IsAzureSql()) { persistence = persistence.Driver(); } @@ -36,6 +36,14 @@ namespace Orchard.Data.Providers { protected override void AlterConfiguration(Configuration config) { config.SetProperty(NHibernate.Cfg.Environment.PrepareSql, Boolean.TrueString); + + if (IsAzureSql()) { + config.SetProperty(NHibernate.Cfg.Environment.TransactionStrategy, typeof(ReliableAdoNetWithDistributedTransactionFactory).AssemblyQualifiedName); + } + } + + private bool IsAzureSql() { + return _connectionString.ToLowerInvariant().Contains("database.windows.net"); } } } \ No newline at end of file