From ef1aa089ad00f3618985b1890d0d9eac0c105a06 Mon Sep 17 00:00:00 2001 From: pushrbx Date: Wed, 2 Sep 2015 13:55:09 +0100 Subject: [PATCH 1/4] fix #8 New class 'RuntimeInfo' has been added to get the Entry assembly's runtime version. SqlBatchOperion.Execute has been changed to check the runtime, and if it's 2.0 or below then apply the workaround for framework bug. --- .../Infrastructure/SqlCommandSet.cs | 6 ++++-- .../Operations/SqlBatchOperation.cs | 7 ++++--- Rhino.Etl.Core/Rhino.Etl.Core.csproj | 4 +++- Rhino.Etl.Core/RuntimeInfo.cs | 20 +++++++++++++++++++ 4 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 Rhino.Etl.Core/RuntimeInfo.cs diff --git a/Rhino.Etl.Core/Infrastructure/SqlCommandSet.cs b/Rhino.Etl.Core/Infrastructure/SqlCommandSet.cs index 66d4c01..f75c196 100644 --- a/Rhino.Etl.Core/Infrastructure/SqlCommandSet.cs +++ b/Rhino.Etl.Core/Infrastructure/SqlCommandSet.cs @@ -113,9 +113,11 @@ public void Append(SqlCommand command) /// private static void AssertHasParameters(SqlCommand command) { - if(command.Parameters.Count==0) + if (command.Parameters.Count == 0 && + (RuntimeInfo.Version.Contains("2.0") || RuntimeInfo.Version.Contains("1.1"))) { - throw new ArgumentException("A command in SqlCommandSet must have parameters. You can't pass hardcoded sql strings."); + throw new ArgumentException( + "A command in SqlCommandSet must have parameters. You can't pass hardcoded sql strings."); } } diff --git a/Rhino.Etl.Core/Operations/SqlBatchOperation.cs b/Rhino.Etl.Core/Operations/SqlBatchOperation.cs index d0a6988..f175091 100644 --- a/Rhino.Etl.Core/Operations/SqlBatchOperation.cs +++ b/Rhino.Etl.Core/Operations/SqlBatchOperation.cs @@ -38,7 +38,7 @@ public int Timeout /// Initializes a new instance of the class. /// /// Name of the connection string. - public SqlBatchOperation(string connectionStringName) + protected SqlBatchOperation(string connectionStringName) : this(ConfigurationManager.ConnectionStrings[connectionStringName]) { } @@ -47,7 +47,7 @@ public SqlBatchOperation(string connectionStringName) /// Initializes a new instance of the class. /// /// The connection string settings to use. - public SqlBatchOperation(ConnectionStringSettings connectionStringSettings) + protected SqlBatchOperation(ConnectionStringSettings connectionStringSettings) : base(connectionStringSettings) { base.paramPrefix = "@"; @@ -66,11 +66,12 @@ public override IEnumerable Execute(IEnumerable rows) { SqlCommandSet commandSet = null; CreateCommandSet(connection, transaction, ref commandSet, timeout); + foreach (Row row in rows) { SqlCommand command = new SqlCommand(); PrepareCommand(row, command); - if (command.Parameters.Count == 0) //workaround around a framework bug + if (command.Parameters.Count == 0 && (RuntimeInfo.Version.Contains("2.0") || RuntimeInfo.Version.Contains("1.1"))) //workaround around a framework bug { Guid guid = Guid.NewGuid(); command.Parameters.AddWithValue(guid.ToString(), guid); diff --git a/Rhino.Etl.Core/Rhino.Etl.Core.csproj b/Rhino.Etl.Core/Rhino.Etl.Core.csproj index 05b6edb..ea604d2 100644 --- a/Rhino.Etl.Core/Rhino.Etl.Core.csproj +++ b/Rhino.Etl.Core/Rhino.Etl.Core.csproj @@ -122,12 +122,13 @@ - + + @@ -150,6 +151,7 @@ false +