text: ﻿// 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 JetBrains.Annotations;
  using Microsoft.EntityFrameworkCore.Metadata;
  using Microsoft.EntityFrameworkCore.Utilities;
  
  namespace Microsoft.EntityFrameworkCore.Cosmos.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 ReadItemExpression : Expression
      {
          private const string RootAlias = "c";
  
          /// <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
              => typeof(object);
  
          /// <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 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 virtual string Container { 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 ProjectionExpression ProjectionExpression { 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 IEntityType EntityType { 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 IDictionary<IProperty, string> PropertyParameters { 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 ReadItemExpression(
              [NotNull] IEntityType entityType,
              [NotNull] IDictionary<IProperty, string> propertyParameters)
          {
              Check.NotNull(entityType, nameof(entityType));
              Check.NotNull(propertyParameters, nameof(propertyParameters));
  
              Container = entityType.GetContainer();
  
              ProjectionExpression = new ProjectionExpression(
                  new EntityProjectionExpression(
                      entityType,
                      new RootReferenceExpression(entityType, RootAlias)),
                  RootAlias);
  
              EntityType = entityType;
  
              PropertyParameters = propertyParameters;
          }
      }
  }
  