From 459ffe428a939836eb6ed06f8b8dde30efbc59af Mon Sep 17 00:00:00 2001 From: ldavis Date: Tue, 9 Aug 2016 12:01:37 -0400 Subject: [PATCH] FutureRunner's command sql is now inside a transaction --- .../Future/FutureRunner.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Source/EntityFramework.Extended/Future/FutureRunner.cs b/Source/EntityFramework.Extended/Future/FutureRunner.cs index b3e841e..dce2079 100644 --- a/Source/EntityFramework.Extended/Future/FutureRunner.cs +++ b/Source/EntityFramework.Extended/Future/FutureRunner.cs @@ -14,6 +14,9 @@ namespace EntityFramework.Future /// public class FutureRunner : IFutureRunner { + private const string _beginTransaction = "BEGIN TRANSACTION;"; + private const string _rollbackTransaction = "ROLLBACK TRANSACTION;"; + /// /// Executes the future queries. /// @@ -71,6 +74,9 @@ private static DbCommand CreateFutureCommand(ObjectContext context, IEnumerable< var futureSql = new StringBuilder(); int queryCount = 0; + if (command.Transaction == null) + futureSql.AppendLine(_beginTransaction); + foreach (IFutureQuery futureQuery in futureQueries) { var plan = futureQuery.GetPlan(context); @@ -111,7 +117,13 @@ private static DbCommand CreateFutureCommand(ObjectContext context, IEnumerable< futureSql.AppendLine(";"); queryCount++; - } // foreach query + } // foreach query + + if (command.Transaction == null) + { + futureSql.AppendLine(); + futureSql.AppendLine(_rollbackTransaction); + } command.CommandText = futureSql.ToString(); if (context.CommandTimeout.HasValue)