Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate COALESCE as ISNULL #34171

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,43 @@ protected override Expression VisitValues(ValuesExpression valuesExpression)
return valuesExpression;
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
protected override Expression VisitSqlFunction(SqlFunctionExpression sqlFunctionExpression)
{
if (sqlFunctionExpression is { IsBuiltIn: true, Arguments: not null }
&& string.Equals(sqlFunctionExpression.Name, "COALESCE", StringComparison.OrdinalIgnoreCase))
{
var head = sqlFunctionExpression.Arguments[0];
if (head.TypeMapping != sqlFunctionExpression.TypeMapping)
{
head = new SqlUnaryExpression(
ExpressionType.Convert,
head,
sqlFunctionExpression.Type,
sqlFunctionExpression.TypeMapping);
}

sqlFunctionExpression = (SqlFunctionExpression)sqlFunctionExpression
.Arguments
.Skip(1)
.Aggregate(head, (l, r) => new SqlFunctionExpression(
"ISNULL",
arguments: [l, r],
nullable: true,
argumentsPropagateNullability: [false, false],
sqlFunctionExpression.Type,
sqlFunctionExpression.TypeMapping
));
}

return base.VisitSqlFunction(sqlFunctionExpression);
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,13 @@ public virtual Task Ternary_should_not_evaluate_both_sides_with_parameter(bool a
}));
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Coalesce_Correct_Type(bool async)
=> AssertQuery(
async,
ss => ss.Set<Customer>().Select(c => c.Region ?? "no region specified"));

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Null_Coalesce_Short_Circuit(bool async)
Expand Down Expand Up @@ -2927,7 +2934,7 @@ public virtual Task Select_Where_Subquery_Equality(bool async)
=> AssertQuery(
async,
ss => from o in ss.Set<Order>().OrderBy(o => o.OrderID).Take(1)
// ReSharper disable once UseMethodAny.0
// ReSharper disable once UseMethodAny.0
where (from od in ss.Set<OrderDetail>().OrderBy(od => od.OrderID).Take(2)
where (from c in ss.Set<Customer>()
where c.CustomerID == o.CustomerID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public override async Task Update_non_owned_property_on_entity_with_owned2(bool
AssertSql(
"""
UPDATE [o]
SET [o].[Title] = COALESCE([o].[Title], N'') + N'_Suffix'
SET [o].[Title] = ISNULL([o].[Title], N'') + N'_Suffix'
FROM [Owner] AS [o]
""");
}
Expand Down Expand Up @@ -184,7 +184,7 @@ public override async Task Update_with_alias_uniquification_in_setter_subquery(b
"""
UPDATE [o]
SET [o].[Total] = (
SELECT COALESCE(SUM([o0].[Amount]), 0)
SELECT ISNULL(SUM([o0].[Amount]), 0)
FROM [OrderProduct] AS [o0]
WHERE [o].[Id] = [o0].[OrderId])
FROM [Orders] AS [o]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ public override async Task Update_Where_set_property_plus_constant(bool async)
AssertExecuteUpdateSql(
"""
UPDATE [c]
SET [c].[ContactName] = COALESCE([c].[ContactName], N'') + N'Abc'
SET [c].[ContactName] = ISNULL([c].[ContactName], N'') + N'Abc'
FROM [Customers] AS [c]
WHERE [c].[CustomerID] LIKE N'F%'
""");
Expand All @@ -1035,11 +1035,11 @@ public override async Task Update_Where_set_property_plus_parameter(bool async)
await base.Update_Where_set_property_plus_parameter(async);

AssertExecuteUpdateSql(
"""
"""
@__value_0='Abc' (Size = 4000)

UPDATE [c]
SET [c].[ContactName] = COALESCE([c].[ContactName], N'') + @__value_0
SET [c].[ContactName] = ISNULL([c].[ContactName], N'') + @__value_0
FROM [Customers] AS [c]
WHERE [c].[CustomerID] LIKE N'F%'
""");
Expand All @@ -1052,7 +1052,7 @@ public override async Task Update_Where_set_property_plus_property(bool async)
AssertExecuteUpdateSql(
"""
UPDATE [c]
SET [c].[ContactName] = COALESCE([c].[ContactName], N'') + [c].[CustomerID]
SET [c].[ContactName] = ISNULL([c].[ContactName], N'') + [c].[CustomerID]
FROM [Customers] AS [c]
WHERE [c].[CustomerID] LIKE N'F%'
""");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2191,7 +2191,7 @@ public override async Task Enum_with_value_converter_matching_take_value(bool as
@__orderItemType_1='MyType1' (Nullable = false) (Size = 4000)
@__p_0='1'

SELECT [o1].[Id], COALESCE((
SELECT [o1].[Id], ISNULL((
SELECT TOP(1) [o3].[Price]
FROM [OrderItems] AS [o3]
WHERE [o1].[Id] = [o3].[OrderId] AND [o3].[Type] = @__orderItemType_1), 0.0E0) AS [SpecialSum]
Expand Down Expand Up @@ -2273,8 +2273,8 @@ public override async Task Group_by_aggregate_in_subquery_projection_after_group

AssertSql(
"""
SELECT [t].[Value] AS [A], COALESCE(SUM([t].[Id]), 0) AS [B], COALESCE((
SELECT TOP(1) COALESCE(SUM([t].[Id]), 0) + COALESCE(SUM([t0].[Id]), 0)
SELECT [t].[Value] AS [A], ISNULL(SUM([t].[Id]), 0) AS [B], ISNULL((
SELECT TOP(1) ISNULL(SUM([t].[Id]), 0) + ISNULL(SUM([t0].[Id]), 0)
FROM [Tables] AS [t0]
GROUP BY [t0].[Value]
ORDER BY (SELECT 1)), 0) AS [C]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,14 @@ FROM [CompetitionSeasons] AS [c1]
SELECT [a].[Id], [a].[ActivityTypeId], [a].[DateTime], [a].[Points], (
SELECT TOP(1) [c].[Id]
FROM [CompetitionSeasons] AS [c]
WHERE [c].[StartDate] <= [a].[DateTime] AND [a].[DateTime] < [c].[EndDate]) AS [CompetitionSeasonId], COALESCE([a].[Points], (
WHERE [c].[StartDate] <= [a].[DateTime] AND [a].[DateTime] < [c].[EndDate]) AS [CompetitionSeasonId], ISNULL(ISNULL([a].[Points], (
SELECT TOP(1) [a1].[Points]
FROM [ActivityTypePoints] AS [a1]
INNER JOIN [CompetitionSeasons] AS [c0] ON [a1].[CompetitionSeasonId] = [c0].[Id]
WHERE [a0].[Id] = [a1].[ActivityTypeId] AND [c0].[Id] = (
SELECT TOP(1) [c1].[Id]
FROM [CompetitionSeasons] AS [c1]
WHERE [c1].[StartDate] <= [a].[DateTime] AND [a].[DateTime] < [c1].[EndDate])), 0) AS [Points]
WHERE [c1].[StartDate] <= [a].[DateTime] AND [a].[DateTime] < [c1].[EndDate]))), 0) AS [Points]
FROM [Activities] AS [a]
INNER JOIN [ActivityType] AS [a0] ON [a].[ActivityTypeId] = [a0].[Id]
""");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ public override async Task Result_operator_nav_prop_reference_optional_Sum(bool

AssertSql(
"""
SELECT COALESCE(SUM([l0].[Level1_Required_Id]), 0)
SELECT ISNULL(SUM([l0].[Level1_Required_Id]), 0)
FROM [LevelOne] AS [l]
LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id]
""");
Expand Down Expand Up @@ -1171,7 +1171,7 @@ public override async Task Result_operator_nav_prop_reference_optional_via_Defau

AssertSql(
"""
SELECT COALESCE(SUM(CASE
SELECT ISNULL(SUM(CASE
WHEN [l0].[Id] IS NULL THEN 0
ELSE [l0].[Level1_Required_Id]
END), 0)
Expand Down Expand Up @@ -2031,7 +2031,7 @@ public override async Task Select_join_with_key_selector_being_a_subquery(bool a
"""
SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id]
FROM [LevelOne] AS [l]
INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = COALESCE((
INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = ISNULL((
SELECT TOP(1) [l1].[Id]
FROM [LevelTwo] AS [l1]
ORDER BY [l1].[Id]), 0)
Expand Down Expand Up @@ -2943,7 +2943,7 @@ public override async Task Select_optional_navigation_property_string_concat(boo

AssertSql(
"""
SELECT COALESCE([l].[Name], N'') + N' ' + COALESCE(CASE
SELECT ISNULL([l].[Name], N'') + N' ' + ISNULL(CASE
WHEN [l1].[Id] IS NOT NULL THEN [l1].[Name]
ELSE N'NULL'
END, N'')
Expand Down Expand Up @@ -3808,7 +3808,7 @@ public override async Task Sum_with_selector_cast_using_as(bool async)

AssertSql(
"""
SELECT COALESCE(SUM([l].[Id]), 0)
SELECT ISNULL(SUM([l].[Id]), 0)
FROM [LevelOne] AS [l]
""");
}
Expand All @@ -3822,7 +3822,7 @@ public override async Task Sum_with_filter_with_include_selector_cast_using_as(b
SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id]
FROM [LevelOne] AS [l]
WHERE [l].[Id] > (
SELECT COALESCE(SUM([l0].[Id]), 0)
SELECT ISNULL(SUM([l0].[Id]), 0)
FROM [LevelTwo] AS [l0]
WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id])
""");
Expand Down Expand Up @@ -3966,7 +3966,7 @@ FROM [LevelOne] AS [l]
LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Id]
GROUP BY [l1].[Name]
HAVING (
SELECT MIN(COALESCE([l5].[Id], 0) + COALESCE([l5].[Id], 0))
SELECT MIN(ISNULL([l5].[Id], 0) + ISNULL([l5].[Id], 0))
FROM [LevelOne] AS [l2]
LEFT JOIN [LevelTwo] AS [l3] ON [l2].[Id] = [l3].[Id]
LEFT JOIN [LevelThree] AS [l4] ON [l3].[Id] = [l4].[Id]
Expand All @@ -3981,7 +3981,7 @@ public override async Task Nested_object_constructed_from_group_key_properties(b

AssertSql(
"""
SELECT [l].[Id], [l].[Name], [l].[Date], [l0].[Id], [l1].[Name], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], COALESCE(SUM(CAST(LEN([l].[Name]) AS int)), 0) AS [Aggregate]
SELECT [l].[Id], [l].[Name], [l].[Date], [l0].[Id], [l1].[Name], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], ISNULL(SUM(CAST(LEN([l].[Name]) AS int)), 0) AS [Aggregate]
FROM [LevelOne] AS [l]
LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id]
LEFT JOIN [LevelTwo] AS [l1] ON [l].[Id] = [l1].[Level1_Required_Id]
Expand Down Expand Up @@ -4107,7 +4107,7 @@ public override async Task Composite_key_join_on_groupby_aggregate_projecting_on
SELECT [l2].[Key]
FROM [LevelOne] AS [l]
INNER JOIN (
SELECT [l1].[Key], COALESCE(SUM([l1].[Id]), 0) AS [Sum]
SELECT [l1].[Key], ISNULL(SUM([l1].[Id]), 0) AS [Sum]
FROM (
SELECT [l0].[Id], [l0].[Id] % 3 AS [Key]
FROM [LevelTwo] AS [l0]
Expand All @@ -4126,7 +4126,7 @@ public override async Task Composite_key_join_on_groupby_aggregate_projecting_on
SELECT [l2].[Key]
FROM [LevelOne] AS [l]
INNER JOIN (
SELECT [l1].[Key], COALESCE(SUM([l1].[Id]), 0) AS [Sum]
SELECT [l1].[Key], ISNULL(SUM([l1].[Id]), 0) AS [Sum]
FROM (
SELECT [l0].[Id], [l0].[Id] % 3 AS [Key]
FROM [LevelTwo] AS [l0]
Expand Down Expand Up @@ -4342,7 +4342,7 @@ WHERE [l].[Id] < 5
CROSS APPLY (
SELECT [l1].[Id], [l1].[Date], [l1].[Name], [l1].[OneToMany_Optional_Self_Inverse1Id], [l1].[OneToMany_Required_Self_Inverse1Id], [l1].[OneToOne_Optional_Self1Id]
FROM [LevelOne] AS [l1]
WHERE [l1].[Id] <> COALESCE([l0].[Level1_Required_Id], 0)
WHERE [l1].[Id] <> ISNULL([l0].[Level1_Required_Id], 0)
) AS [l2]
""");
}
Expand Down Expand Up @@ -4450,7 +4450,7 @@ FROM [LevelOne] AS [l]
LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Id]
GROUP BY [l1].[Name]
HAVING (
SELECT MIN(COALESCE([l5].[Id], 0))
SELECT MIN(ISNULL([l5].[Id], 0))
FROM [LevelOne] AS [l2]
LEFT JOIN [LevelTwo] AS [l3] ON [l2].[Id] = [l3].[Id]
LEFT JOIN [LevelThree] AS [l4] ON [l3].[Id] = [l4].[Id]
Expand Down Expand Up @@ -4832,7 +4832,7 @@ ORDER BY [l].[Id]
) AS [l4]
LEFT JOIN (
SELECT [l0].[Id], [l1].[Id] AS [Id0], [l2].[Id] AS [Id1], CASE
WHEN COALESCE((
WHEN ISNULL((
SELECT MAX([l3].[Id])
FROM [LevelFour] AS [l3]
WHERE [l1].[Id] IS NOT NULL AND [l1].[Id] = [l3].[OneToMany_Optional_Inverse4Id]), 0) > 1 THEN CAST(1 AS bit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ WHEN [l3].[Level2_Required_Id] IS NOT NULL AND [l3].[OneToMany_Required_Inverse3
END
GROUP BY [l3].[Level3_Name]
HAVING (
SELECT MIN(COALESCE(CASE
SELECT MIN(ISNULL(CASE
WHEN [l10].[OneToOne_Required_PK_Date] IS NOT NULL AND [l10].[Level1_Required_Id] IS NOT NULL AND [l10].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l10].[Id]
END, 0))
FROM [Level1] AS [l4]
Expand Down Expand Up @@ -370,7 +370,7 @@ public override async Task Result_operator_nav_prop_reference_optional_via_Defau

AssertSql(
"""
SELECT COALESCE(SUM(CASE
SELECT ISNULL(SUM(CASE
WHEN [s].[OneToOne_Required_PK_Date] IS NULL OR [s].[Level1_Required_Id] IS NULL OR [s].[OneToMany_Required_Inverse2Id] IS NULL THEN 0
ELSE [s].[Level1_Required_Id]
END), 0)
Expand Down Expand Up @@ -539,9 +539,9 @@ WHEN [l3].[Level2_Required_Id] IS NOT NULL AND [l3].[OneToMany_Required_Inverse3
END
GROUP BY [l3].[Level3_Name]
HAVING (
SELECT MIN(COALESCE(CASE
SELECT MIN(ISNULL(CASE
WHEN [l10].[OneToOne_Required_PK_Date] IS NOT NULL AND [l10].[Level1_Required_Id] IS NOT NULL AND [l10].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l10].[Id]
END, 0) + COALESCE(CASE
END, 0) + ISNULL(CASE
WHEN [l10].[OneToOne_Required_PK_Date] IS NOT NULL AND [l10].[Level1_Required_Id] IS NOT NULL AND [l10].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l10].[Id]
END, 0))
FROM [Level1] AS [l4]
Expand Down Expand Up @@ -578,7 +578,7 @@ public override async Task Sum_with_selector_cast_using_as(bool async)

AssertSql(
"""
SELECT COALESCE(SUM([l].[Id]), 0)
SELECT ISNULL(SUM([l].[Id]), 0)
FROM [Level1] AS [l]
""");
}
Expand All @@ -592,7 +592,7 @@ public override async Task Sum_with_filter_with_include_selector_cast_using_as(b
SELECT [l].[Id], [l].[Date], [l].[Name]
FROM [Level1] AS [l]
WHERE [l].[Id] > (
SELECT COALESCE(SUM(CASE
SELECT ISNULL(SUM(CASE
WHEN [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l0].[Id]
END), 0)
FROM [Level1] AS [l0]
Expand Down Expand Up @@ -783,7 +783,7 @@ public override async Task Nested_object_constructed_from_group_key_properties(b

AssertSql(
"""
SELECT [s].[Id], [s].[Name], [s].[Date], [s].[InnerId] AS [Id], [s].[Level2_Name0] AS [Name], [s].[OneToOne_Required_PK_Date] AS [Date], [s].[Level1_Optional_Id], [s].[Level1_Required_Id], COALESCE(SUM(CAST(LEN([s].[Name]) AS int)), 0) AS [Aggregate]
SELECT [s].[Id], [s].[Name], [s].[Date], [s].[InnerId] AS [Id], [s].[Level2_Name0] AS [Name], [s].[OneToOne_Required_PK_Date] AS [Date], [s].[Level1_Optional_Id], [s].[Level1_Required_Id], ISNULL(SUM(CAST(LEN([s].[Name]) AS int)), 0) AS [Aggregate]
FROM (
SELECT [l].[Id], [l].[Date], [l].[Name], [l1].[OneToOne_Required_PK_Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l3].[Level2_Name] AS [Level2_Name0], CASE
WHEN [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l1].[Id]
Expand Down Expand Up @@ -879,7 +879,7 @@ SELECT [s1].[Key]
FROM [Level1] AS [l]
INNER JOIN (
SELECT [s].[Key], (
SELECT COALESCE(SUM(CASE
SELECT ISNULL(SUM(CASE
WHEN [l7].[OneToOne_Required_PK_Date] IS NOT NULL AND [l7].[Level1_Required_Id] IS NOT NULL AND [l7].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l7].[Id]
END), 0)
FROM (
Expand Down Expand Up @@ -933,7 +933,7 @@ SELECT [s1].[Key]
FROM [Level1] AS [l]
INNER JOIN (
SELECT [s].[Key], (
SELECT COALESCE(SUM(CASE
SELECT ISNULL(SUM(CASE
WHEN [l7].[OneToOne_Required_PK_Date] IS NOT NULL AND [l7].[Level1_Required_Id] IS NOT NULL AND [l7].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l7].[Id]
END), 0)
FROM (
Expand Down Expand Up @@ -1620,7 +1620,7 @@ WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id]
CROSS APPLY (
SELECT [l2].[Id], [l2].[Date], [l2].[Name]
FROM [Level1] AS [l2]
WHERE [l2].[Id] <> COALESCE([s].[Level1_Required_Id], 0)
WHERE [l2].[Id] <> ISNULL([s].[Level1_Required_Id], 0)
) AS [l3]
""");
}
Expand Down Expand Up @@ -1906,7 +1906,7 @@ WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id]
WHEN [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l2].[Id]
END
WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL
) AS [s] ON [l].[Id] = COALESCE((
) AS [s] ON [l].[Id] = ISNULL((
SELECT TOP(1) CASE
WHEN [l5].[OneToOne_Required_PK_Date] IS NOT NULL AND [l5].[Level1_Required_Id] IS NOT NULL AND [l5].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l5].[Id]
END
Expand Down Expand Up @@ -3650,7 +3650,7 @@ public override async Task Result_operator_nav_prop_reference_optional_Sum(bool

AssertSql(
"""
SELECT COALESCE(SUM([l1].[Level1_Required_Id]), 0)
SELECT ISNULL(SUM([l1].[Level1_Required_Id]), 0)
FROM [Level1] AS [l]
LEFT JOIN (
SELECT [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id]
Expand Down Expand Up @@ -5898,7 +5898,7 @@ public override async Task Select_optional_navigation_property_string_concat(boo

AssertSql(
"""
SELECT COALESCE([l].[Name], N'') + N' ' + COALESCE(CASE
SELECT ISNULL([l].[Name], N'') + N' ' + ISNULL(CASE
WHEN [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] IS NOT NULL AND [l1].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l1].[Level2_Name]
ELSE N'NULL'
END, N'')
Expand Down Expand Up @@ -8388,7 +8388,7 @@ WHEN [l2].[Level2_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse3
END AS [Id0], CASE
WHEN [l4].[Level3_Required_Id] IS NOT NULL AND [l4].[OneToMany_Required_Inverse4Id] IS NOT NULL THEN [l4].[Id]
END AS [Id1], CASE
WHEN COALESCE((
WHEN ISNULL((
SELECT MAX(CASE
WHEN [l5].[Level3_Required_Id] IS NOT NULL AND [l5].[OneToMany_Required_Inverse4Id] IS NOT NULL THEN [l5].[Id]
END)
Expand Down
Loading
Loading