-
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: Index based bindings for projection
Resolves #17620
- Loading branch information
Showing
27 changed files
with
1,621 additions
and
1,232 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
12 changes: 12 additions & 0 deletions
12
src/EFCore.InMemory/Properties/InMemoryStrings.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
128 changes: 128 additions & 0 deletions
128
src/EFCore.InMemory/Query/Internal/CollectionResultShaperExpression.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,128 @@ | ||
// 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.Collections.Generic; | ||
using System.Linq.Expressions; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Microsoft.EntityFrameworkCore.Metadata; | ||
using Microsoft.EntityFrameworkCore.Query; | ||
using Microsoft.EntityFrameworkCore.Utilities; | ||
|
||
namespace Microsoft.EntityFrameworkCore.InMemory.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 CollectionResultShaperExpression : Expression, IPrintableExpression | ||
{ | ||
/// <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 CollectionResultShaperExpression( | ||
Expression projection, | ||
Expression innerShaper, | ||
INavigationBase? navigation, | ||
Type elementType) | ||
{ | ||
Check.NotNull(projection, nameof(projection)); | ||
Check.NotNull(innerShaper, nameof(innerShaper)); | ||
|
||
Projection = projection; | ||
InnerShaper = innerShaper; | ||
Navigation = navigation; | ||
ElementType = elementType; | ||
} | ||
|
||
/// <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 virtual Expression Projection { get; } | ||
|
||
/// <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 virtual Expression InnerShaper { get; } | ||
|
||
/// <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 virtual INavigationBase? Navigation { get; } | ||
|
||
/// <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 virtual Type ElementType { get; } | ||
|
||
/// <inheritdoc /> | ||
public sealed override ExpressionType NodeType | ||
=> ExpressionType.Extension; | ||
|
||
/// <inheritdoc /> | ||
public override Type Type | ||
=> Navigation?.ClrType ?? typeof(List<>).MakeGenericType(ElementType); | ||
|
||
/// <inheritdoc /> | ||
protected override Expression VisitChildren(ExpressionVisitor visitor) | ||
{ | ||
Check.NotNull(visitor, nameof(visitor)); | ||
|
||
var projection = visitor.Visit(Projection); | ||
var innerShaper = visitor.Visit(InnerShaper); | ||
|
||
return Update(projection, innerShaper); | ||
} | ||
|
||
/// <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 virtual CollectionResultShaperExpression Update( | ||
Expression projection, | ||
Expression innerShaper) | ||
{ | ||
Check.NotNull(projection, nameof(projection)); | ||
Check.NotNull(innerShaper, nameof(innerShaper)); | ||
|
||
return projection != Projection || innerShaper != InnerShaper | ||
? new CollectionResultShaperExpression(projection, innerShaper, Navigation, ElementType) | ||
: this; | ||
} | ||
|
||
/// <inheritdoc /> | ||
void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) | ||
{ | ||
Check.NotNull(expressionPrinter, nameof(expressionPrinter)); | ||
|
||
expressionPrinter.AppendLine("CollectionResultShaperExpression:"); | ||
using (expressionPrinter.Indent()) | ||
{ | ||
expressionPrinter.Append("("); | ||
expressionPrinter.Visit(Projection); | ||
expressionPrinter.Append(", "); | ||
expressionPrinter.Visit(InnerShaper); | ||
expressionPrinter.AppendLine($", {Navigation?.Name}, {ElementType.ShortDisplayName()})"); | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.