Skip to content

Commit

Permalink
Query: Remove obsoleted code
Browse files Browse the repository at this point in the history
Part of #22549

Only touched code relating to query
  • Loading branch information
smitpatel committed Oct 28, 2021
1 parent 5fb9f37 commit f51ea1c
Show file tree
Hide file tree
Showing 29 changed files with 155 additions and 1,209 deletions.
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

0 comments on commit f51ea1c

Please sign in to comment.