Skip to content

Commit

Permalink
Query: Don't skip any parameter in projection
Browse files Browse the repository at this point in the history
We used to skip enumerable parameter because of group join but it is dead code now

Resolves #26964
  • Loading branch information
smitpatel committed Dec 14, 2021
1 parent 0e1e95b commit ba40f09
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,6 @@ public virtual Expression Translate(InMemoryQueryExpression queryExpression, Exp
|| expression is EntityShaperExpression
|| expression is IncludeExpression))
{
// This skips the group parameter from GroupJoin
if (expression is ParameterExpression parameter
&& parameter.Type.IsGenericType
&& parameter.Type.GetGenericTypeDefinition() == typeof(IEnumerable<>))
{
return parameter;
}

if (_indexBasedBinding)
{
switch (expression)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,6 @@ public virtual Expression Translate(SelectExpression selectExpression, Expressio
|| expression is EntityShaperExpression
|| expression is IncludeExpression))
{
// This skips the group parameter from GroupJoin
if (expression is ParameterExpression parameter
&& parameter.Type.IsGenericType
&& parameter.Type.GetGenericTypeDefinition() == typeof(IEnumerable<>))
{
return parameter;
}

if (_indexBasedBinding)
{
switch (expression)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1269,6 +1269,10 @@ public override async Task Reverse_after_orderBy_and_take(bool async)
Assert.Equal(CosmosStrings.ReverseAfterSkipTakeNotSupported, message);
}

[ConditionalTheory(Skip = "Issue #17246")]
public override Task Using_enumerable_parameter_in_projection(bool async)
=> base.Using_enumerable_parameter_in_projection(async);

private void AssertSql(params string[] expected)
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2390,4 +2390,32 @@ public virtual Task MemberInit_in_projection_without_arguments(bool async)
AssertEqual(e.CustomerID, a.CustomerID);
AssertEqual(e.Orders.Count(), a.Orders.Count());
});



[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Using_enumerable_parameter_in_projection(bool async)
{
var customersToLoad = new List<string> { "A" };
var results = new List<OrderDto>();

return AssertQuery(
async,
ss => ss.Set<Customer>()
.Where(c => c.CustomerID.StartsWith("F"))
.Select(c => new
{
c.CustomerID,
Orders = customersToLoad.Contains("FISSA")
? c.Orders.Select(e => new OrderDto())
: results
}),
elementSorter: e => e.CustomerID,
elementAsserter: (e, a) =>
{
AssertEqual(e.CustomerID, a.CustomerID);
AssertEqual(e.Orders.Count(), a.Orders.Count());
});
}
}

0 comments on commit ba40f09

Please sign in to comment.