Beispiel #1
0
        protected virtual Expression VisitMethodCallNewArray(NewArrayExpression newArrayExpression)
        {
            // Needed for MySqlDbFunctionsExtensions.Match() and String.Concat() translation.
            if (newArrayExpression.Type == typeof(string[]))
            {
                return(_sqlExpressionFactory.ComplexFunctionArgument(
                           newArrayExpression.Expressions.Select(e => (SqlExpression)Visit(e))
                           .ToArray(),
                           ", ",
                           typeof(string[])));
            }

            // Needed for String.Concat() translation.
            if (newArrayExpression.Type == typeof(object[]))
            {
                var typeMapping = ((MySqlStringTypeMapping)Dependencies.TypeMappingSource.GetMapping(typeof(string))).Clone(forceToString: true);
                return(_sqlExpressionFactory.ComplexFunctionArgument(
                           newArrayExpression.Expressions.Select(e => Dependencies.SqlExpressionFactory.ApplyTypeMapping((SqlExpression)Visit(e), typeMapping))
                           .ToArray(),
                           ", ",
                           typeof(object[]),
                           typeMapping));
            }

            return(base.VisitNewArray(newArrayExpression));
        }
 protected override Expression VisitNewArray(NewArrayExpression newArrayExpression)
 {
     // Needed for MySqlDbFunctionsExtensions.Match().
     // Could be made more specific in the future, if needed.
     return(newArrayExpression.Type == typeof(string[])
         ? _sqlExpressionFactory.ComplexFunctionArgument(
                newArrayExpression.Expressions.Select(e => (SqlExpression)Visit(e))
                .ToArray(),
                ", ",
                typeof(string))
         : base.VisitNewArray(newArrayExpression));
 }