示例#1
0
 public override void Visit(DbCastExpression expression)
 {
     Write(expression);
     _depth++;
     Write("Argument", expression.Argument);
     _depth--;
 }
        public override Expression Visit(DbCastExpression expression)
        {
            Expression source = this.Visit(expression.Argument);
            Type resultType = edmTypeConverter.Convert(expression.ResultType);

            if (resultType == typeof(string))
            {
                return Expression.Call(
                    null,
                    StringFunctions.ConvertToString,
                    Expression.Convert(source, typeof(object)));
            }

            var resType = TypeHelper.MakeNotNullable(resultType);

            if (source.Type == typeof(string) && TypeHelper.IsNumeric(resType))
            {
                return Expression.Call(
                    null,
                    StringFunctions.ParseString.MakeGenericMethod(resType),
                    source);
            }

            return Expression.Convert(source, resultType);
        }
示例#3
0
        public override LegacyCommandTrees.DbExpression Visit(DbCastExpression expression)
        {
            Debug.Assert(expression != null, "expression != null");

            return
                (expression.Argument.Accept(this).CastTo(expression.ResultType.ToLegacyEdmTypeUsage()));
        }
            /// <summary>
            /// Casts argument to expression.
            /// </summary>
            /// <param name="node">Cast expression node</param>
            /// <returns>Result of casting argument</returns>
            public override PropagatorResult Visit(DbCastExpression node)
            {
                Debug.Assert(null != node, "node is not visited when null");

                PropagatorResult childResult = Visit(node.Argument);
                TypeUsage        nodeType    = node.ResultType;

                if (!childResult.IsSimple || BuiltInTypeKind.PrimitiveType != nodeType.EdmType.BuiltInTypeKind)
                {
                    throw EntityUtil.NotSupported(Strings.Update_UnsupportedCastArgument(nodeType.EdmType.Name));
                }

                object resultValue;

                if (childResult.IsNull)
                {
                    resultValue = null;
                }
                else
                {
                    try
                    {
                        resultValue = Cast(childResult.GetSimpleValue(), ((PrimitiveType)nodeType.EdmType).ClrEquivalentType);
                    }
                    catch
                    {
                        Debug.Fail("view generator failed to validate cast in update mapping view");
                        throw;
                    }
                }

                PropagatorResult result = childResult.ReplicateResultWithNewValue(resultValue);

                return(result);
            }
示例#5
0
        public override void Visit(DbCastExpression e)
        {
            Check.NotNull(e, "e");

            BeginUnary(e);
            End(e);
        }
示例#6
0
        public override Expression Visit(DbCastExpression expression)
        {
            Expression source     = this.Visit(expression.Argument);
            Type       resultType = edmTypeConverter.Convert(expression.ResultType);

            if (resultType == typeof(string))
            {
                return(Expression.Call(
                           null,
                           StringFunctions.ConvertToString,
                           Expression.Convert(source, typeof(object))));
            }

            var resType = TypeHelper.MakeNotNullable(resultType);

            if (source.Type == typeof(string) && TypeHelper.IsNumeric(resType))
            {
                return(Expression.Call(
                           null,
                           StringFunctions.ParseString.MakeGenericMethod(resType),
                           source));
            }

            return(Expression.Convert(source, resultType));
        }
示例#7
0
        /// <summary>
        /// Implements the visitor pattern for <see cref="T:System.Data.Common.CommandTrees.DbCastExpression"/>.
        /// </summary>
        /// <param name="expression">The <see cref="T:System.Data.Common.CommandTrees.DbCastExpression"/> that is visited.</param>
        public override void Visit(DbCastExpression expression)
        {
            if (expression == null)
            {
                throw new ArgumentNullException("expression");
            }

            expression.Argument.Accept(this);
        }
        public override Expression Visit(DbCastExpression expression)
        {
            Expression source = this.Visit(expression.Argument);
            Type resultType = edmTypeConverter.Convert(expression.ResultType);

            if (resultType == typeof(string))
            {
                return Expression.Call(
                    null,
                    StringFunctions.ConvertToString,
                    Expression.Convert(source, typeof(object)));
            }

            return Expression.Convert(source, resultType);
        }
示例#9
0
        public override Expression Visit(DbCastExpression expression)
        {
            Expression source     = this.Visit(expression.Argument);
            Type       resultType = edmTypeConverter.Convert(expression.ResultType);

            if (resultType == typeof(string))
            {
                return(Expression.Call(
                           null,
                           StringFunctions.ConvertToString,
                           Expression.Convert(source, typeof(object))));
            }

            return(Expression.Convert(source, resultType));
        }
示例#10
0
        /// <inheritdoc/>
        public override void Visit(DbCastExpression e)
        {
            var sourceSqlType = e.SourceColumn.GetSqlType();
            var targetSqlType = e.TargetColumn.GetSqlType();

            if (CanEliminateCast(sourceSqlType, targetSqlType))
            {
                e.Operand.Accept(this);
            }
            else
            {
                SqlBuilder.Append("CAST(");
                e.Operand.Accept(this);
                SqlBuilder.Append(" AS ");
                SqlBuilder.Append(targetSqlType.GetDataTypeSql(this.SqlVersion));
                SqlBuilder.Append(")");
            }
        }
            /// <summary>
            ///     Casts argument to expression.
            /// </summary>
            /// <param name="node"> Cast expression node </param>
            /// <returns> Result of casting argument </returns>
            public override PropagatorResult Visit(DbCastExpression node)
            {
                Check.NotNull(node, "node");

                var childResult = Visit(node.Argument);
                var nodeType    = node.ResultType;

                if (!childResult.IsSimple ||
                    BuiltInTypeKind.PrimitiveType != nodeType.EdmType.BuiltInTypeKind)
                {
                    throw new NotSupportedException(Strings.Update_UnsupportedCastArgument(nodeType.EdmType.Name));
                }

                object resultValue;

                if (childResult.IsNull)
                {
                    resultValue = null;
                }
                else
                {
                    try
                    {
                        resultValue = Cast(childResult.GetSimpleValue(), ((PrimitiveType)nodeType.EdmType).ClrEquivalentType);
                    }
                    catch
                    {
                        Debug.Fail("view generator failed to validate cast in update mapping view");
                        throw;
                    }
                }

                var result = childResult.ReplicateResultWithNewValue(resultValue);

                return(result);
            }
示例#12
0
        /// <summary>
        /// Implements the visitor pattern for <see cref="T:System.Data.Common.CommandTrees.DbCastExpression"/>.
        /// </summary>
        /// <param name="expression">The <see cref="T:System.Data.Common.CommandTrees.DbCastExpression"/> that is visited.</param>
        public override void Visit(DbCastExpression expression)
        {
            if (expression == null)
            {
                throw new ArgumentNullException("expression");
            }

            expression.Argument.Accept(this);
        }
示例#13
0
 public override void Visit(DbCastExpression expression)
 {
   VisitUnaryExpression(expression);
 }
示例#14
0
 public override TreeNode Visit(DbCastExpression e)
 {
     Check.NotNull <DbCastExpression>(e, nameof(e));
     return(this.VisitCastOrTreat("Cast", (DbUnaryExpression)e));
 }
 public override void Visit(DbCastExpression e)
 {
     VisitCastOrTreat(e);
 }
示例#16
0
 public override void Visit(DbCastExpression expression)
 {
     throw new NotSupportedException("Visit(\"DbCastExpression\") is not supported.");
 }
示例#17
0
 public override SqlFragment Visit(DbCastExpression expression)
 {
     //TODO: handle casting
     return(expression.Argument.Accept(this));
 }
        public override void Visit(DbCastExpression e)
        {
            Check.NotNull(e, "e");

            VisitCastOrTreat(e);
        }
        /// <summary>
        ///     Visitor pattern method for <see cref="DbCastExpression" />.
        /// </summary>
        /// <param name="expression"> The DbCastExpression that is being visited. </param>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="expression" />
        ///     is null
        /// </exception>
        public override void Visit(DbCastExpression expression)
        {
            Check.NotNull(expression, "expression");

            VisitUnaryExpression(expression);
        }
示例#20
0
            public override DbExpressionEntitySetInfo Visit(DbCastExpression expression)
            {
                Check.NotNull(expression, "expression");

                return(null);
            }
 public override void Visit(DbCastExpression e)
 {
     BeginUnary(e);
     End(e);
 }
示例#22
0
 public override VfpExpression Visit(DbCastExpression expression)
 {
     return(new VfpCastExpression(expression.ResultType, expression.Argument.Accept(this)));
 }
示例#23
0
 /// <summary>
 ///     Typed visitor pattern method for DbCastExpression.
 /// </summary>
 /// <param name="expression"> The DbCastExpression that is being visited. </param>
 /// <returns> An instance of TResultType. </returns>
 public abstract TResultType Visit(DbCastExpression expression);
示例#24
0
 public override TReturn Visit(DbCastExpression expression)
 {
     Check.NotNull <DbCastExpression>(expression, nameof(expression));
     throw this.ConstructNotSupportedException((DbExpression)expression);
 }
示例#25
0
 public override void Visit(DbCastExpression e)
 {
     Check.NotNull <DbCastExpression>(e, nameof(e));
     this.VisitCastOrTreat((DbUnaryExpression)e);
 }
 public override TReturn Visit(DbCastExpression expression)
 {
     throw ConstructNotSupportedException(expression);
 }
示例#27
0
 public override DbExpression Visit(DbCastExpression expression)
 {
     System.Diagnostics.Debug.Print("Visit(DbCastExpression): {0}", expression);
     return(base.Visit(expression));
 }
示例#28
0
            public override TreeNode Visit(DbCastExpression e)
            {
                Check.NotNull(e, "e");

                return(VisitCastOrTreat("Cast", e));
            }
示例#29
0
 public override object Visit(DbCastExpression expression)
 {
     this.Visit(expression.Argument);
     return(null);
 }
示例#30
0
 public override bool Visit(DbCastExpression expression)
 {
     return(VisitUnaryExpression(expression));
 }
        public override void Visit(DbCastExpression e)
        {
            Check.NotNull(e, "e");

            BeginUnary(e);
            End(e);
        }
示例#32
0
 public override TreeNode Visit(DbCastExpression e)
 {
     return(VisitCastOrTreat("Cast", e));
 }
		public override void Visit(DbCastExpression expression)
		{
			throw new NotSupportedException("Visit(\"CastExpression\") is not supported.");
		}
示例#34
0
 /// <summary>
 /// Visits the <see cref="DbCastExpression"/>.
 /// </summary>
 /// <param name="expression">The expression.</param>
 /// <returns>The result.</returns>
 public abstract T Visit(DbCastExpression expression);
 public override void Visit(DbCastExpression expression)
 {
     VisitUnaryExpression(expression);
 }
示例#36
0
 public override bool Visit(DbCastExpression expression)
 {
     Check.NotNull <DbCastExpression>(expression, nameof(expression));
     return(this.VisitUnaryExpression((DbUnaryExpression)expression));
 }
示例#37
0
 public override void Visit(DbCastExpression e)
 {
     VisitCastOrTreat(e);
 }
 public override DbExpression Visit(DbCastExpression expression)
 {
     System.Diagnostics.Debug.Print("Visit(DbCastExpression): {0}", expression);
     return base.Visit(expression);
 }
示例#39
0
 public override ISqlFragment Visit(DbCastExpression e)
 {
     return(new SqlBuilder("cast(", e.Argument.Accept(this), " as ", MetadataHelpers.GetSqlPrimitiveType(e.ResultType), ")"));
 }
        public override void Visit(DbCastExpression e)
        {
            Check.NotNull(e, "e");

            VisitCastOrTreat(e);
        }
 public override void Visit(DbCastExpression expression)
 {
     Contract.Requires(expression != null);
 }
 public override void Visit(DbCastExpression expression) { }
示例#43
0
 public override DbExpressionEntitySetInfo Visit(DbCastExpression expression)
 {
     return(null);
 }
 /// <summary>
 ///     Visitor pattern method for DbCastExpression.
 /// </summary>
 /// <param name="expression"> The DbCastExpression that is being visited. </param>
 public abstract void Visit(DbCastExpression expression);