public virtual Expression BindNavigation(INavigation navigation, bool clientEval)
        {
            if (!EntityType.IsAssignableFrom(navigation.DeclaringEntityType) &&
                !navigation.DeclaringEntityType.IsAssignableFrom(EntityType))
            {
                throw new InvalidOperationException(
                          $"Called EntityProjectionExpression.GetNavigation() with incorrect INavigation. EntityType:{EntityType.DisplayName()}, Navigation:{navigation.Name}");
            }

            if (!_navigationExpressionsCache.TryGetValue(navigation, out var expression))
            {
                if (navigation.IsCollection())
                {
                    expression = new ObjectArrayProjectionExpression(navigation, AccessExpression);
                }
                else
                {
                    expression = new EntityProjectionExpression(
                        navigation.GetTargetType(),
                        new ObjectAccessExpression(navigation, AccessExpression));
                }

                _navigationExpressionsCache[navigation] = expression;
            }

            if (!clientEval &&
                expression.Name.Length == 0)
            {
                // Non-persisted navigation can't be translated
                return(null);
            }

            return((Expression)expression);
        }
Beispiel #2
0
        public ObjectArrayProjectionExpression(
            INavigation navigation, Expression accessExpression, EntityProjectionExpression innerProjection = null)
        {
            var targetType = navigation.GetTargetType();

            Type = typeof(IEnumerable <>).MakeGenericType(targetType.ClrType);

            Name = targetType.GetContainingPropertyName();
            if (Name == null)
            {
                throw new InvalidOperationException(
                          $"Navigation '{navigation.DeclaringEntityType.DisplayName()}.{navigation.Name}' doesn't point to an embedded entity.");
            }

            Navigation       = navigation;
            AccessExpression = accessExpression;
            InnerProjection  = innerProjection ?? new EntityProjectionExpression(
                targetType,
                new RootReferenceExpression(targetType, ""));
        }
Beispiel #3
0
 public virtual ObjectArrayProjectionExpression Update(Expression accessExpression, EntityProjectionExpression innerProjection)
 => accessExpression != AccessExpression || innerProjection != InnerProjection
         ? new ObjectArrayProjectionExpression(Navigation, accessExpression, innerProjection)
         : 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>
 protected abstract Expression VisitEntityProjection(EntityProjectionExpression entityProjectionExpression);
 public SelectExpression(IEntityType entityType)
 {
     Container      = "c";// entityType.GetContainer();
     FromExpression = new RootReferenceExpression(entityType, RootAlias);
     _projectionMapping[new ProjectionMember()] = new EntityProjectionExpression(entityType, FromExpression);
 }
 /// <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 int AddToProjection(EntityProjectionExpression entityProjection) => AddToProjection(entityProjection, null);
Beispiel #7
0
 protected override Expression VisitEntityProjection(EntityProjectionExpression entityProjectionExpression)
 {
     throw new NotImplementedException();
 }