-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Query: Convert MaterializeCollectionNavigation to expression from met…
…hodCall For easier processing in the tree
- Loading branch information
Showing
4 changed files
with
54 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/EFCore/Query/NavigationExpansion/MaterializeCollectionNavigationExpression.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// 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; | ||
using System.Linq.Expressions; | ||
using JetBrains.Annotations; | ||
using Microsoft.EntityFrameworkCore.Metadata; | ||
using Microsoft.EntityFrameworkCore.Query.Expressions.Internal; | ||
using Microsoft.EntityFrameworkCore.Query.Internal; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Query.NavigationExpansion | ||
{ | ||
public class MaterializeCollectionNavigationExpression : Expression, IPrintable | ||
{ | ||
public MaterializeCollectionNavigationExpression(Expression subquery, INavigation navigation) | ||
{ | ||
Subquery = subquery; | ||
Navigation = navigation; | ||
} | ||
|
||
public virtual Expression Subquery { get; } | ||
public virtual INavigation Navigation { get; } | ||
|
||
public override ExpressionType NodeType => ExpressionType.Extension; | ||
public override Type Type => Navigation.ClrType; | ||
|
||
public virtual void Print(ExpressionPrinter expressionPrinter) | ||
{ | ||
expressionPrinter.StringBuilder.Append($"MaterializeCollectionNavigation({Navigation}, "); | ||
expressionPrinter.Visit(Subquery); | ||
expressionPrinter.StringBuilder.Append(")"); | ||
} | ||
|
||
protected override Expression VisitChildren(ExpressionVisitor visitor) | ||
{ | ||
var subquery = visitor.Visit(Subquery); | ||
|
||
return subquery != Subquery | ||
? new MaterializeCollectionNavigationExpression(subquery, Navigation) | ||
: this; | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters