Beispiel #1
0
 /// <summary>
 /// Visitor pattern method for <see cref="T:System.Data.Entity.Core.Common.CommandTrees.DbPropertyExpression" />.
 /// </summary>
 /// <param name="expression"> The DbPropertyExpression that is being visited. </param>
 /// <exception cref="T:System.ArgumentNullException">
 /// <paramref name="expression" />
 /// is null
 /// </exception>
 public override void Visit(DbPropertyExpression expression)
 {
     Check.NotNull <DbPropertyExpression>(expression, nameof(expression));
     if (expression.Instance == null)
     {
         return;
     }
     this.VisitExpression(expression.Instance);
 }
Beispiel #2
0
        /// <summary>
        ///     Visitor pattern method for <see cref="DbPropertyExpression" />.
        /// </summary>
        /// <param name="expression"> The DbPropertyExpression that is being visited. </param>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="expression" />
        ///     is null
        /// </exception>
        public override void Visit(DbPropertyExpression expression)
        {
            Check.NotNull(expression, "expression");

            if (expression.Instance != null)
            {
                VisitExpression(expression.Instance);
            }
        }
        public override DbExpression Visit(DbPropertyExpression expression)
        {
            Check.NotNull(expression, "expression");

            DbExpression result      = expression;
            var          newInstance = VisitExpression(expression.Instance);

            if (!ReferenceEquals(expression.Instance, newInstance))
            {
                result = CqtBuilder.Property(newInstance, expression.Property.Name);
            }
            NotifyIfChanged(expression, result);
            return(result);
        }
        /// <summary>Implements the visitor pattern for retrieving an instance property.</summary>
        /// <returns>The implemented visitor.</returns>
        /// <param name="expression">The expression.</param>
        public override DbExpression Visit(DbPropertyExpression expression)
        {
            Check.NotNull(expression, "expression");

            DbExpression result      = expression;
            var          newInstance = VisitExpression(expression.Instance);

            if (!ReferenceEquals(expression.Instance, newInstance))
            {
                if (Helper.IsRelationshipEndMember(expression.Property))
                {
                    RelationshipEndMember endMember;
                    if (!TryGetMember(newInstance, expression.Property.Name, out endMember))
                    {
                        var type = newInstance.ResultType.EdmType;
                        throw new ArgumentException(
                                  Strings.Cqt_Copier_EndNotFound(
                                      expression.Property.Name, TypeHelpers.GetFullName(type.NamespaceName, type.Name)));
                    }
                    result = newInstance.Property(endMember);
                }
                else if (Helper.IsNavigationProperty(expression.Property))
                {
                    NavigationProperty navProp;
                    if (!TryGetMember(newInstance, expression.Property.Name, out navProp))
                    {
                        var type = newInstance.ResultType.EdmType;
                        throw new ArgumentException(
                                  Strings.Cqt_Copier_NavPropertyNotFound(
                                      expression.Property.Name, TypeHelpers.GetFullName(type.NamespaceName, type.Name)));
                    }
                    result = newInstance.Property(navProp);
                }
                else
                {
                    EdmProperty prop;
                    if (!TryGetMember(newInstance, expression.Property.Name, out prop))
                    {
                        var type = newInstance.ResultType.EdmType;
                        throw new ArgumentException(
                                  Strings.Cqt_Copier_PropertyNotFound(
                                      expression.Property.Name, TypeHelpers.GetFullName(type.NamespaceName, type.Name)));
                    }
                    result = newInstance.Property(prop);
                }
            }
            return(result);
        }
Beispiel #5
0
        /// <summary>Implements the visitor pattern for retrieving an instance property.</summary>
        /// <returns>The implemented visitor.</returns>
        /// <param name="expression">The expression.</param>
        public override DbExpression Visit(DbPropertyExpression expression)
        {
            Check.NotNull <DbPropertyExpression>(expression, nameof(expression));
            DbExpression dbExpression = (DbExpression)expression;
            DbExpression instance     = this.VisitExpression(expression.Instance);

            if (!object.ReferenceEquals((object)expression.Instance, (object)instance))
            {
                if (Helper.IsRelationshipEndMember(expression.Property))
                {
                    RelationshipEndMember member;
                    if (!DbExpressionRebinder.TryGetMember <RelationshipEndMember>(instance, expression.Property.Name, out member))
                    {
                        EdmType edmType = instance.ResultType.EdmType;
                        throw new ArgumentException(Strings.Cqt_Copier_EndNotFound((object)expression.Property.Name, (object)TypeHelpers.GetFullName(edmType.NamespaceName, edmType.Name)));
                    }
                    dbExpression = (DbExpression)instance.Property(member);
                }
                else if (Helper.IsNavigationProperty(expression.Property))
                {
                    NavigationProperty member;
                    if (!DbExpressionRebinder.TryGetMember <NavigationProperty>(instance, expression.Property.Name, out member))
                    {
                        EdmType edmType = instance.ResultType.EdmType;
                        throw new ArgumentException(Strings.Cqt_Copier_NavPropertyNotFound((object)expression.Property.Name, (object)TypeHelpers.GetFullName(edmType.NamespaceName, edmType.Name)));
                    }
                    dbExpression = (DbExpression)instance.Property(member);
                }
                else
                {
                    EdmProperty member;
                    if (!DbExpressionRebinder.TryGetMember <EdmProperty>(instance, expression.Property.Name, out member))
                    {
                        EdmType edmType = instance.ResultType.EdmType;
                        throw new ArgumentException(Strings.Cqt_Copier_PropertyNotFound((object)expression.Property.Name, (object)TypeHelpers.GetFullName(edmType.NamespaceName, edmType.Name)));
                    }
                    dbExpression = (DbExpression)instance.Property(member);
                }
            }
            return(dbExpression);
        }
 /// <summary>
 /// When overridden in a derived class, implements the visitor pattern for
 /// <see
 ///     cref="T:System.Data.Entity.Core.Common.CommandTrees.DbPropertyExpression" />
 /// .
 /// </summary>
 /// <returns>A result value of a specific type.</returns>
 /// <param name="expression">
 /// The <see cref="T:System.Data.Entity.Core.Common.CommandTrees.DbPropertyExpression" /> that is being visited.
 /// </param>
 public abstract TResultType Visit(DbPropertyExpression expression);
 /// <summary>
 /// When overridden in a derived class, implements the visitor pattern for
 /// <see cref="T:System.Data.Entity.Core.Common.CommandTrees.DbPropertyExpression" />
 /// .
 /// </summary>
 /// <param name="expression">
 /// The <see cref="T:System.Data.Entity.Core.Common.CommandTrees.DbPropertyExpression" /> that is visited.
 /// </param>
 public abstract void Visit(DbPropertyExpression expression);
 public override void Visit(DbPropertyExpression expression)
 {
 }