-
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.
Merge branch 'release/6.0-rc2' into release/6.0
- Loading branch information
Showing
21 changed files
with
681 additions
and
208 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
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
51 changes: 51 additions & 0 deletions
51
src/EFCore.Relational/Query/Internal/QueryExpressionReplacingExpressionVisitor.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,51 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Diagnostics.CodeAnalysis; | ||
using System.Linq.Expressions; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Query.Internal | ||
{ | ||
/// <summary> | ||
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to | ||
/// the same compatibility standards as public APIs. It may be changed or removed without notice in | ||
/// any release. You should only use it directly in your code with extreme caution and knowing that | ||
/// doing so can result in application failures when updating to a new Entity Framework Core release. | ||
/// </summary> | ||
public class QueryExpressionReplacingExpressionVisitor : ExpressionVisitor | ||
{ | ||
private readonly Expression _oldQuery; | ||
private readonly Expression _newQuery; | ||
|
||
/// <summary> | ||
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to | ||
/// the same compatibility standards as public APIs. It may be changed or removed without notice in | ||
/// any release. You should only use it directly in your code with extreme caution and knowing that | ||
/// doing so can result in application failures when updating to a new Entity Framework Core release. | ||
/// </summary> | ||
public QueryExpressionReplacingExpressionVisitor(Expression oldQuery, Expression newQuery) | ||
{ | ||
_oldQuery = oldQuery; | ||
_newQuery = newQuery; | ||
} | ||
|
||
/// <summary> | ||
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to | ||
/// the same compatibility standards as public APIs. It may be changed or removed without notice in | ||
/// any release. You should only use it directly in your code with extreme caution and knowing that | ||
/// doing so can result in application failures when updating to a new Entity Framework Core release. | ||
/// </summary> | ||
[return: NotNullIfNotNull("expression")] | ||
public override Expression? Visit(Expression? expression) | ||
{ | ||
return expression is ProjectionBindingExpression projectionBindingExpression | ||
&& ReferenceEquals(projectionBindingExpression.QueryExpression, _oldQuery) | ||
? projectionBindingExpression.ProjectionMember != null | ||
? new ProjectionBindingExpression( | ||
_newQuery, projectionBindingExpression.ProjectionMember!, projectionBindingExpression.Type) | ||
: new ProjectionBindingExpression( | ||
_newQuery, projectionBindingExpression.Index!.Value, projectionBindingExpression.Type) | ||
: base.Visit(expression); | ||
} | ||
} | ||
} |
Oops, something went wrong.