Example #1
0
        public override void ReplaceWith(SqlExpression expression)
        {
            ArgumentValidator.EnsureArgumentNotNull(expression, "expression");
            ArgumentValidator.EnsureArgumentIs <SqlTrim>(expression, "expression");
            var replacingExpression = (SqlTrim)expression;

            this.expression = replacingExpression.expression;
            trimCharacters  = replacingExpression.trimCharacters;
            trimType        = replacingExpression.TrimType;
        }
Example #2
0
 /// <inheritdoc/>
 public override string Translate(SqlTrimType type)
 {
     return(string.Empty);
 }
Example #3
0
 internal SqlTrim(SqlExpression expression, string trimCharacters, SqlTrimType trimType) : base(SqlNodeType.Trim)
 {
     this.expression     = expression;
     this.trimCharacters = trimCharacters;
     this.trimType       = trimType;
 }
Example #4
0
        private static SqlExpression GenericTrim(SqlExpression _this, SqlExpression trimChars, SqlTrimType trimType)
        {
            if (trimChars is SqlNull)
            {
                return(SqlDml.Trim(_this, trimType));
            }
            var container = trimChars as SqlContainer;

            if (container.IsNullReference())
            {
                throw new NotSupportedException(Strings.ExStringTrimSupportedOnlyWithConstants);
            }
            var chars = container.Value as char[];

            if (chars == null)
            {
                throw new NotSupportedException(Strings.ExStringTrimSupportedOnlyWithConstants);
            }
            return(chars.Length == 0
        ? SqlDml.Trim(_this, trimType)
        : SqlDml.Trim(_this, trimType, new string(chars)));
        }
Example #5
0
 private static SqlExpression GenericTrim(SqlExpression _this, SqlExpression trimChars, SqlTrimType trimType)
 {
     if (trimChars is SqlNull)
     {
         return(SqlDml.Trim(_this, trimType));
     }
     if (!(trimChars is SqlContainer container))
     {
         throw new NotSupportedException(Strings.ExStringTrimSupportedOnlyWithConstants);
     }
     if (!(container.Value is char[] chars))
     {
         throw new NotSupportedException(Strings.ExStringTrimSupportedOnlyWithConstants);
     }
     return(chars.Length == 0
 ? SqlDml.Trim(_this, trimType)
 : SqlDml.Trim(_this, trimType, new string(chars)));
 }