Skip to content

Commit

Permalink
Revert "Add quirks for #9551"
Browse files Browse the repository at this point in the history
This reverts commit 9b3a514.
  • Loading branch information
smitpatel committed Oct 4, 2017
1 parent 71da832 commit 0b4c3de
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 95 deletions.
10 changes: 1 addition & 9 deletions src/EFCore/Query/EntityQueryModelVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,7 @@ protected virtual void OptimizeQueryModel(

navigationRewritingExpressionVisitor.Rewrite(queryModel, parentQueryModel: null);

if (AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue9551", out var isEnabled)
&& isEnabled)
{
includeCompiler.RewriteCollectionQueries(queryModel);
}
else
{
includeCompiler.RewriteCollectionQueries();
}
includeCompiler.RewriteCollectionQueries();

includeCompiler.LogIgnoredIncludes();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using Remotion.Linq.Clauses;
using Remotion.Linq.Clauses.Expressions;
using Remotion.Linq.Clauses.ResultOperators;
using System;

namespace Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.Internal
{
Expand Down Expand Up @@ -107,12 +106,6 @@ protected override Expression VisitQuerySourceReference(QuerySourceReferenceExpr
/// </summary>
protected override Expression VisitSubQuery(SubQueryExpression subQueryExpression)
{
if (AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue9551", out var isEnabled)
&& isEnabled)
{
return base.VisitSubQuery(subQueryExpression);
}

if (_reachable)
{
return subQueryExpression;
Expand Down
44 changes: 9 additions & 35 deletions src/EFCore/Query/Internal/IncludeCompiler.IncludeLoadTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Remotion.Linq;
using Remotion.Linq.Clauses;
using Remotion.Linq.Clauses.Expressions;
using System;

namespace Microsoft.EntityFrameworkCore.Query.Internal
{
Expand Down Expand Up @@ -35,10 +34,16 @@ public void Compile(

if (querySourceReferenceExpression.ReferencedQuerySource is GroupJoinClause groupJoinClause)
{
if (AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue9551", out var isEnabled)
&& isEnabled)
if (queryModel.GetOutputExpression() is SubQueryExpression subQueryExpression
&& subQueryExpression.QueryModel.SelectClause.Selector is QuerySourceReferenceExpression qsre
&& (qsre.ReferencedQuerySource as MainFromClause)?.FromExpression == QuerySourceReferenceExpression)
{
// GJs expand to 'from e in [g] select e' so we can rewrite the projector
querySourceReferenceExpression = qsre;
queryModel = subQueryExpression.QueryModel;
}
else
{
// We expand GJs to 'from e in [g] select e' so we can rewrite the projector

var joinClause = groupJoinClause.JoinClause;

Expand All @@ -57,37 +62,6 @@ var subQueryModel

queryModel = subQueryModel;
}
else
{
if (queryModel.GetOutputExpression() is SubQueryExpression subQueryExpression
&& subQueryExpression.QueryModel.SelectClause.Selector is QuerySourceReferenceExpression qsre
&& (qsre.ReferencedQuerySource as MainFromClause)?.FromExpression == QuerySourceReferenceExpression)
{
querySourceReferenceExpression = qsre;
queryModel = subQueryExpression.QueryModel;
}
else
{
// We expand GJs to 'from e in [g] select e' so we can rewrite the projector

var joinClause = groupJoinClause.JoinClause;

var mainFromClause
= new MainFromClause(joinClause.ItemName, joinClause.ItemType, QuerySourceReferenceExpression);

querySourceReferenceExpression = new QuerySourceReferenceExpression(mainFromClause);

var subQueryModel
= new QueryModel(
mainFromClause,
new SelectClause(querySourceReferenceExpression));

ApplyIncludeExpressionsToQueryModel(
queryModel, QuerySourceReferenceExpression, new SubQueryExpression(subQueryModel));

queryModel = subQueryModel;
}
}
}

Compile(
Expand Down
68 changes: 24 additions & 44 deletions src/EFCore/Query/Internal/IncludeCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,32 +76,16 @@ public virtual void CompileIncludes(
return;
}

if (AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue9551", out var isEnabled)
&& isEnabled)
{
foreach (var includeLoadTree in CreateIncludeLoadTrees(queryModel))
{
includeLoadTree.Compile(
_queryCompilationContext,
queryModel,
trackingQuery,
asyncQuery,
ref _collectionIncludeId);
}
}
else
{
_targetQueryModel = _targetQueryModel ?? queryModel;
_targetQueryModel = _targetQueryModel ?? queryModel;

foreach (var includeLoadTree in CreateIncludeLoadTrees(queryModel))
{
includeLoadTree.Compile(
_queryCompilationContext,
_targetQueryModel,
trackingQuery,
asyncQuery,
ref _collectionIncludeId);
}
foreach (var includeLoadTree in CreateIncludeLoadTrees(queryModel))
{
includeLoadTree.Compile(
_queryCompilationContext,
_targetQueryModel,
trackingQuery,
asyncQuery,
ref _collectionIncludeId);
}
}

Expand Down Expand Up @@ -166,26 +150,22 @@ var querySourceReferenceExpression
continue;
}

if (!(AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue9551", out var isEnabled)
&& isEnabled))
if (querySourceReferenceExpression.Type.IsGrouping()
&& querySourceTracingExpressionVisitor.OriginGroupByQueryModel != null)
{
if (querySourceReferenceExpression.Type.IsGrouping()
&& querySourceTracingExpressionVisitor.OriginGroupByQueryModel != null)
{
querySourceReferenceExpression
= querySourceTracingExpressionVisitor
.FindResultQuerySourceReferenceExpression(
querySourceTracingExpressionVisitor.OriginGroupByQueryModel.GetOutputExpression(),
includeResultOperator.QuerySource);

_targetQueryModel = querySourceTracingExpressionVisitor.OriginGroupByQueryModel;
}

if (querySourceReferenceExpression == null
|| querySourceReferenceExpression.Type.IsGrouping())
{
continue;
}
querySourceReferenceExpression
= querySourceTracingExpressionVisitor
.FindResultQuerySourceReferenceExpression(
querySourceTracingExpressionVisitor.OriginGroupByQueryModel.GetOutputExpression(),
includeResultOperator.QuerySource);

_targetQueryModel = querySourceTracingExpressionVisitor.OriginGroupByQueryModel;
}

if (querySourceReferenceExpression == null
|| querySourceReferenceExpression.Type.IsGrouping())
{
continue;
}

var includeLoadTree
Expand Down

0 comments on commit 0b4c3de

Please sign in to comment.