-
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.
InMemory: Support for non-scalar single result in projection
Part of #16963
- Loading branch information
Showing
9 changed files
with
135 additions
and
62 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
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
54 changes: 54 additions & 0 deletions
54
src/EFCore.InMemory/Query/Internal/SingleResultShaperExpression.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,54 @@ | ||
// 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 Microsoft.EntityFrameworkCore.Query; | ||
|
||
namespace Microsoft.EntityFrameworkCore.InMemory.Query.Internal | ||
{ | ||
public class SingleResultShaperExpression : Expression, IPrintableExpression | ||
{ | ||
public SingleResultShaperExpression( | ||
Expression projection, | ||
Expression innerShaper, | ||
Type type) | ||
{ | ||
Projection = projection; | ||
InnerShaper = innerShaper; | ||
Type = type; | ||
} | ||
|
||
protected override Expression VisitChildren(ExpressionVisitor visitor) | ||
{ | ||
var projection = visitor.Visit(Projection); | ||
var innerShaper = visitor.Visit(InnerShaper); | ||
|
||
return Update(projection, innerShaper); | ||
} | ||
|
||
public virtual SingleResultShaperExpression Update(Expression projection, Expression innerShaper) | ||
=> projection != Projection || innerShaper != InnerShaper | ||
? new SingleResultShaperExpression(projection, innerShaper, Type) | ||
: this; | ||
|
||
public sealed override ExpressionType NodeType => ExpressionType.Extension; | ||
public override Type Type { get; } | ||
|
||
public virtual Expression Projection { get; } | ||
public virtual Expression InnerShaper { get; } | ||
|
||
public virtual void Print(ExpressionPrinter expressionPrinter) | ||
{ | ||
expressionPrinter.AppendLine($"{nameof(SingleResultShaperExpression)}:"); | ||
using (expressionPrinter.Indent()) | ||
{ | ||
expressionPrinter.Append("("); | ||
expressionPrinter.Visit(Projection); | ||
expressionPrinter.Append(", "); | ||
expressionPrinter.Visit(InnerShaper); | ||
expressionPrinter.AppendLine($")"); | ||
} | ||
} | ||
} | ||
} |
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