Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query: Remove obsoleted code #26475

Merged
1 commit merged into from
Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 146 additions & 0 deletions src/EFCore.Cosmos/Query/Internal/CollectionShaperExpression.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Utilities;

namespace Microsoft.EntityFrameworkCore.Query
{
/// <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 CollectionShaperExpression : 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 CollectionShaperExpression(
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; }

/// <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 sealed override ExpressionType NodeType
=> ExpressionType.Extension;

/// <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 override Type Type
=> Navigation?.ClrType ?? typeof(List<>).MakeGenericType(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>
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 CollectionShaperExpression Update(
Expression projection,
Expression innerShaper)
{
Check.NotNull(projection, nameof(projection));
Check.NotNull(innerShaper, nameof(innerShaper));

return projection != Projection || innerShaper != InnerShaper
? new CollectionShaperExpression(projection, innerShaper, Navigation, ElementType)
: this;
}

/// <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>
void IPrintableExpression.Print(ExpressionPrinter expressionPrinter)
{
Check.NotNull(expressionPrinter, nameof(expressionPrinter));

expressionPrinter.AppendLine("CollectionShaper:");
using (expressionPrinter.Indent())
{
expressionPrinter.Append("(");
expressionPrinter.Visit(Projection);
expressionPrinter.Append(", ");
expressionPrinter.Visit(InnerShaper);
expressionPrinter.AppendLine($", {Navigation?.Name})");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,10 @@ private static readonly MethodInfo _getParameterValueMethodInfo
private SelectExpression _selectExpression;
private bool _clientEval;

private readonly IDictionary<ProjectionMember, Expression> _projectionMapping
= new Dictionary<ProjectionMember, Expression>();

private readonly Dictionary<ProjectionMember, Expression> _projectionMapping = new();
private readonly Stack<ProjectionMember> _projectionMembers = new();

#pragma warning disable CS0618 // Type or member is obsolete
private readonly IDictionary<ParameterExpression, CollectionShaperExpression> _collectionShaperMapping
= new Dictionary<ParameterExpression, CollectionShaperExpression>();
#pragma warning restore CS0618 // Type or member is obsolete

private readonly Stack<INavigation> _includedNavigations
= new();
private readonly Dictionary<ParameterExpression, CollectionShaperExpression> _collectionShaperMapping = new();
private readonly Stack<INavigation> _includedNavigations = new();

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,31 +227,6 @@ public override ShapedQueryExpression TranslateSubquery(Expression expression)
throw new InvalidOperationException(CoreStrings.TranslationFailed(expression.Print()));
}

/// <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>
[Obsolete("Use overload which takes IEntityType.")]
protected override ShapedQueryExpression CreateShapedQueryExpression(Type elementType)
{
Check.NotNull(elementType, nameof(elementType));

var entityType = _queryCompilationContext.Model.FindEntityType(elementType);
var selectExpression = _sqlExpressionFactory.Select(entityType);

return new ShapedQueryExpression(
selectExpression,
new EntityShaperExpression(
entityType,
new ProjectionBindingExpression(
selectExpression,
new ProjectionMember(),
typeof(ValueBuffer)),
false));
}

/// <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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,6 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp
return base.VisitMethodCall(methodCallExpression);
}

/// <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>
[Obsolete("Use overload which takes IEntityType.")]
protected override ShapedQueryExpression CreateShapedQueryExpression(Type elementType)
{
Check.NotNull(elementType, nameof(elementType));

// Let it throw if null found.
return CreateShapedQueryExpression(_model.FindEntityType(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
Expand Down
12 changes: 0 additions & 12 deletions src/EFCore.Relational/Query/EntityProjectionExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,6 @@ public class EntityProjectionExpression : Expression
private readonly IReadOnlyDictionary<IProperty, ColumnExpression> _propertyExpressionMap;
private readonly Dictionary<INavigation, EntityShaperExpression> _ownedNavigationMap = new();

/// <summary>
/// Creates a new instance of the <see cref="EntityProjectionExpression" /> class.
/// </summary>
/// <param name="entityType">The entity type to shape.</param>
/// <param name="innerTable">The table from which entity columns are being projected out.</param>
/// <param name="nullable">A bool value indicating whether this entity instance can be null.</param>
[Obsolete("Use the constructor which takes populated column expressions map.", error: true)]
public EntityProjectionExpression(IEntityType entityType, TableExpressionBase innerTable, bool nullable)
{
throw new NotSupportedException("Obsolete: Use the constructor which takes populated column expressions map.");
}

/// <summary>
/// Creates a new instance of the <see cref="EntityProjectionExpression" /> class.
/// </summary>
Expand Down
Loading