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); }
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); }
public override void Visit(DbCastExpression e) { Check.NotNull(e, "e"); BeginUnary(e); End(e); }
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)); }
/// <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); }
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)); }
/// <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); }
public override void Visit(DbCastExpression expression) { VisitUnaryExpression(expression); }
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); }
public override void Visit(DbCastExpression expression) { throw new NotSupportedException("Visit(\"DbCastExpression\") is not supported."); }
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); }
public override DbExpressionEntitySetInfo Visit(DbCastExpression expression) { Check.NotNull(expression, "expression"); return(null); }
public override void Visit(DbCastExpression e) { BeginUnary(e); End(e); }
public override VfpExpression Visit(DbCastExpression expression) { return(new VfpCastExpression(expression.ResultType, expression.Argument.Accept(this))); }
/// <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);
public override TReturn Visit(DbCastExpression expression) { Check.NotNull <DbCastExpression>(expression, nameof(expression)); throw this.ConstructNotSupportedException((DbExpression)expression); }
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); }
public override DbExpression Visit(DbCastExpression expression) { System.Diagnostics.Debug.Print("Visit(DbCastExpression): {0}", expression); return(base.Visit(expression)); }
public override TreeNode Visit(DbCastExpression e) { Check.NotNull(e, "e"); return(VisitCastOrTreat("Cast", e)); }
public override object Visit(DbCastExpression expression) { this.Visit(expression.Argument); return(null); }
public override bool Visit(DbCastExpression expression) { return(VisitUnaryExpression(expression)); }
public override TreeNode Visit(DbCastExpression e) { return(VisitCastOrTreat("Cast", e)); }
public override void Visit(DbCastExpression expression) { throw new NotSupportedException("Visit(\"CastExpression\") is not supported."); }
/// <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 bool Visit(DbCastExpression expression) { Check.NotNull <DbCastExpression>(expression, nameof(expression)); return(this.VisitUnaryExpression((DbUnaryExpression)expression)); }
public override DbExpression Visit(DbCastExpression expression) { System.Diagnostics.Debug.Print("Visit(DbCastExpression): {0}", expression); return base.Visit(expression); }
public override ISqlFragment Visit(DbCastExpression e) { return(new SqlBuilder("cast(", e.Argument.Accept(this), " as ", MetadataHelpers.GetSqlPrimitiveType(e.ResultType), ")")); }
public override void Visit(DbCastExpression expression) { Contract.Requires(expression != null); }
public override void Visit(DbCastExpression expression) { }
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);