diff --git a/PetaPoco/Utilities/ParametersHelper.cs b/PetaPoco/Utilities/ParametersHelper.cs index ea7c5aa3..196aeb5a 100644 --- a/PetaPoco/Utilities/ParametersHelper.cs +++ b/PetaPoco/Utilities/ParametersHelper.cs @@ -68,11 +68,16 @@ public static string ProcessParams(string sql, object[] args_src, List a } else { - args_dest.Add(arg_val); + var argValCopy = arg_val; + if (argValCopy is ICloneable) + { // Using a clone prevents the error "The SqlParameter is already contained by another SqlParameterCollection" if the parameter is a SqlParameter, rather than a value type. + argValCopy = ((ICloneable)argValCopy).Clone(); + } + args_dest.Add(argValCopy); return "@" + (args_dest.Count - 1).ToString(); } } ); } } -} \ No newline at end of file +}