Skip to content

Commit

Permalink
Query: Unwind nested invocation expressions
Browse files Browse the repository at this point in the history
Resolves #19511
Issue: When we unwound the first level, we did not visit it recursively.
  • Loading branch information
smitpatel committed Jan 8, 2020
1 parent 11e7fc6 commit 8d88a82
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ protected override Expression VisitInvocation(InvocationExpression invocationExp
var invokedExpression = StripTrivialConversions(invocationExpression.Expression);

return invokedExpression is LambdaExpression lambdaExpression
? 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 @@ -1561,6 +1561,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 async)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1527,6 +1527,26 @@ public virtual Task Where_expression_invoke_2(bool async)
entryCount: 6);
}

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Where_expression_invoke_3(bool async)
{
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(
async,
ss => ss.Set<Customer>().Where(lambda),
entryCount: 1);
}

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

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

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 async)
{
await base.Where_concat_string_int_comparison1(async);
Expand Down

0 comments on commit 8d88a82

Please sign in to comment.