Skip to content

Commit 1ca9462

Browse files
committed
Parameter values should be logged using InvariantCulture
Fixes issue dotnet#2316
1 parent e98abc9 commit 1ca9462

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

‎src/EntityFramework.Relational/RelationalLoggerExtensions.cs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.Data;
66
using System.Data.Common;
7+
using System.Globalization;
78
using System.Text;
89
using JetBrains.Annotations;
910
using Microsoft.Data.Entity.Relational;
@@ -25,11 +26,11 @@ public static void LogParameters([NotNull] this ILogger logger, [NotNull] DbPara
2526
}
2627
var paramList = new StringBuilder();
2728

28-
paramList.AppendFormat("{0}: {1}", (parameters[0]).ParameterName, (parameters[0]).Value);
29+
paramList.AppendFormat("{0}: {1}", (parameters[0]).ParameterName, Convert.ToString((parameters[0]).Value, CultureInfo.InvariantCulture));
2930
for (var i = 1; i < parameters.Count; i++)
3031
{
3132
paramList.AppendLine();
32-
paramList.AppendFormat("{0}: {1}", (parameters[i]).ParameterName, (parameters[i]).Value);
33+
paramList.AppendFormat(CultureInfo.InvariantCulture, "{0}: {1}", (parameters[i]).ParameterName, Convert.ToString((parameters[i]).Value, CultureInfo.InvariantCulture));
3334
}
3435
logger.LogDebug(RelationalLoggingEventIds.Sql, paramList.ToString());
3536
}

‎test/EntityFramework.SqlServer.FunctionalTests/FromSqlQuerySqlServerTest.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ public override void From_sql_queryable_multiple_composed_with_closure_parameter
6969
base.From_sql_queryable_multiple_composed_with_closure_parameters();
7070

7171
Assert.Equal(
72-
@"@p0: 1/1/1997 12:00:00 AM
73-
@p1: 1/1/1998 12:00:00 AM
72+
@"@p0: 01/01/1997 00:00:00
73+
@p1: 01/01/1998 00:00:00
7474
7575
SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate]
7676
FROM (

‎test/EntityFramework.SqlServer.FunctionalTests/QuerySqlServerTest.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2389,7 +2389,7 @@ public override void Where_chain()
23892389
base.Where_chain();
23902390

23912391
Assert.Equal(
2392-
@"@__p_0: 1/1/1998 12:00:00 AM
2392+
@"@__p_0: 01/01/1998 00:00:00
23932393
23942394
SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate]
23952395
FROM [Orders] AS [o]

0 commit comments

Comments
 (0)