diff --git a/test/EFCore.Specification.Tests/Query/NorthwindFunctionsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindFunctionsQueryTestBase.cs index 29aa6b231cb..130c86aacff 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindFunctionsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindFunctionsQueryTestBase.cs @@ -1858,12 +1858,12 @@ public virtual Task Where_DateOnly_FromDateTime(bool async) public virtual Task Select_ToString_IndexOf(bool async) => AssertQuery( async, - ss => ss.Set().Select(x => x.OrderID.ToString().IndexOf("123"))); + ss => ss.Set().Where(x => x.OrderID.ToString().IndexOf("123") == -1)); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Select_IndexOf_ToString(bool async) => AssertQuery( async, - ss => ss.Set().Select(x => "123".IndexOf(x.OrderID.ToString()))); + ss => ss.Set().Where(x => "123".IndexOf(x.OrderID.ToString()) == -1)); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServerTest.cs index 254839d42da..640920331a4 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServerTest.cs @@ -2729,8 +2729,9 @@ public override async Task Select_ToString_IndexOf(bool async) AssertSql( """ -SELECT CAST(CHARINDEX(N'123', CONVERT(varchar(11), [o].[OrderID])) AS int) - 1 +SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] +WHERE CAST(CHARINDEX(N'123', CONVERT(varchar(11), [o].[OrderID])) AS int) - 1 = -1 """); } @@ -2740,11 +2741,12 @@ public override async Task Select_IndexOf_ToString(bool async) AssertSql( """ -SELECT CASE +SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] +FROM [Orders] AS [o] +WHERE CASE WHEN CONVERT(varchar(11), [o].[OrderID]) = N'' THEN 0 ELSE CAST(CHARINDEX(CONVERT(varchar(11), [o].[OrderID]), N'123') AS int) - 1 -END -FROM [Orders] AS [o] +END = -1 """); } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindFunctionsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindFunctionsQuerySqliteTest.cs index 39867c717f3..826c4d1b27f 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindFunctionsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindFunctionsQuerySqliteTest.cs @@ -1486,8 +1486,9 @@ public override async Task Select_ToString_IndexOf(bool async) AssertSql( """ -SELECT instr(CAST("o"."OrderID" AS TEXT), '123') - 1 +SELECT "o"."OrderID", "o"."CustomerID", "o"."EmployeeID", "o"."OrderDate" FROM "Orders" AS "o" +WHERE instr(CAST("o"."OrderID" AS TEXT), '123') - 1 = -1 """); } @@ -1497,8 +1498,9 @@ public override async Task Select_IndexOf_ToString(bool async) AssertSql( """ -SELECT instr('123', CAST("o"."OrderID" AS TEXT)) - 1 +SELECT "o"."OrderID", "o"."CustomerID", "o"."EmployeeID", "o"."OrderDate" FROM "Orders" AS "o" +WHERE instr('123', CAST("o"."OrderID" AS TEXT)) - 1 = -1 """); }