diff --git a/test/EFCore.Relational.Specification.Tests/Query/FromSqlQueryTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/FromSqlQueryTestBase.cs index ba8aef0ab2d..1670118aa06 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/FromSqlQueryTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/FromSqlQueryTestBase.cs @@ -733,6 +733,21 @@ public virtual void FromSqlRaw_with_dbParameter() } } + [Fact] + public virtual void FromSqlRaw_with_dbParameter_without_name_prefix() + { + using (var context = CreateContext()) + { + var parameter = CreateDbParameter("city", "London"); + + var actual = context.Customers.FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [City] = @city"), parameter) + .ToArray(); + + Assert.Equal(6, actual.Length); + Assert.True(actual.All(c => c.City == "London")); + } + } + [ConditionalFact] public virtual void FromSqlRaw_with_dbParameter_mixed() { @@ -904,9 +919,28 @@ public virtual void FromSqlInterpolated_with_inlined_db_parameter() { var parameter = CreateDbParameter("@somename", "ALFKI"); - var query = context.Customers + var actual = context.Customers .FromSqlInterpolated(NormalizeDelimetersInInterpolatedString($"SELECT * FROM [Customers] WHERE [CustomerID] = {parameter}")) .ToList(); + + Assert.Equal(1, actual.Count); + Assert.True(actual.All(c => c.City == "Berlin")); + } + } + + [ConditionalFact] + public virtual void FromSqlInterpolated_with_inlined_db_parameter_without_name_prefix() + { + using (var context = CreateContext()) + { + var parameter = CreateDbParameter("somename", "ALFKI"); + + var actual = context.Customers + .FromSqlInterpolated(NormalizeDelimetersInInterpolatedString($"SELECT * FROM [Customers] WHERE [CustomerID] = {parameter}")) + .ToList(); + + Assert.Equal(1, actual.Count); + Assert.True(actual.All(c => c.City == "Berlin")); } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/FromSqlQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/FromSqlQuerySqlServerTest.cs index 5662ffae5ca..fd94b912598 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/FromSqlQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/FromSqlQuerySqlServerTest.cs @@ -409,6 +409,15 @@ public override void FromSqlRaw_with_dbParameter() AssertSql( @"@city='London' (Nullable = false) (Size = 6) +SELECT * FROM ""Customers"" WHERE ""City"" = @city"); + } + + public override void FromSqlRaw_with_dbParameter_without_name_prefix() + { + base.FromSqlRaw_with_dbParameter_without_name_prefix(); + AssertSql( + @"city='London' (Nullable = false) (Size = 6) + SELECT * FROM ""Customers"" WHERE ""City"" = @city"); } @@ -481,6 +490,16 @@ public override void FromSqlInterpolated_with_inlined_db_parameter() AssertSql( @"@somename='ALFKI' (Nullable = false) (Size = 5) +SELECT * FROM ""Customers"" WHERE ""CustomerID"" = @somename"); + } + + public override void FromSqlInterpolated_with_inlined_db_parameter_without_name_prefix() + { + base.FromSqlInterpolated_with_inlined_db_parameter_without_name_prefix(); + + AssertSql( + @"somename='ALFKI' (Nullable = false) (Size = 5) + SELECT * FROM ""Customers"" WHERE ""CustomerID"" = @somename"); } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/FromSqlQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/FromSqlQuerySqliteTest.cs index 451ab3a792e..5905e4556e9 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/FromSqlQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/FromSqlQuerySqliteTest.cs @@ -42,5 +42,6 @@ protected override DbParameter CreateDbParameter(string name, object value) ParameterName = name, Value = value }; + } }