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

[release/3.1] Query: Unwind nested invocation expressions #22472

Merged
merged 1 commit into from
Sep 10, 2020
Merged
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Collections.Generic;
using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Linq.Expressions;
Expand All @@ -14,8 +14,11 @@ protected override Expression VisitInvocation(InvocationExpression invocationExp
{
var invokedExpression = StripTrivialConversions(invocationExpression.Expression);


return invokedExpression is LambdaExpression lambdaExpression
? InlineLambdaExpression(lambdaExpression, invocationExpression.Arguments)
? AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue19511", out var isEnabled) && isEnabled
? InlineLambdaExpression(lambdaExpression, invocationExpression.Arguments)
: Visit(InlineLambdaExpression(lambdaExpression, invocationExpression.Arguments))
: base.VisitInvocation(invocationExpression);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1536,6 +1536,16 @@ FROM root c
WHERE ((c[""Discriminator""] = ""Customer"") AND (c[""CustomerID""] = ""ALFKI""))");
}

public override async Task Where_expression_invoke_3(bool async)
{
await base.Where_expression_invoke_3(async);

AssertSql(
@"SELECT c
FROM root c
WHERE ((c[""Discriminator""] = ""Customer"") AND (c[""CustomerID""] = ""ALFKI""))");
}

[ConditionalTheory(Skip = "Issue #17246")]
public override async Task Where_concat_string_int_comparison1(bool isAsync)
{
Expand Down
20 changes: 20 additions & 0 deletions test/EFCore.Specification.Tests/Query/SimpleQueryTestBase.Where.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1519,6 +1519,26 @@ public virtual Task Where_expression_invoke_2(bool isAsync)
entryCount: 6);
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Where_expression_invoke_3(bool isAsync)
{
Expression<Func<Customer, bool>> lambda3 = c => c.CustomerID == "ALFKI";
var customerParameter2 = Expression.Parameter(typeof(Customer));
var lambda2 = Expression.Lambda<Func<Customer, bool>>(
Expression.Invoke(lambda3, customerParameter2),
customerParameter2);

var customerParameter = Expression.Parameter(typeof(Customer));
var lambda = Expression.Lambda<Func<Customer, bool>>(
Expression.Invoke(lambda2, customerParameter),
customerParameter);
return AssertQuery(
isAsync,
ss => ss.Set<Customer>().Where(lambda),
entryCount: 1);
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Where_concat_string_int_comparison1(bool isAsync)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,16 @@ FROM [Orders] AS [o]
WHERE [c].[CustomerID] = N'ALFKI'");
}

public override async Task Where_expression_invoke_3(bool isAsync)
{
await base.Where_expression_invoke_3(isAsync);

AssertSql(
@"SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region]
FROM [Customers] AS [c]
WHERE [c].[CustomerID] = N'ALFKI'");
}

public override async Task Where_concat_string_int_comparison1(bool isAsync)
{
await base.Where_concat_string_int_comparison1(isAsync);
Expand Down