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; }
/// <inheritdoc/> public override string Translate(SqlTrimType type) { return(string.Empty); }
internal SqlTrim(SqlExpression expression, string trimCharacters, SqlTrimType trimType) : base(SqlNodeType.Trim) { this.expression = expression; this.trimCharacters = trimCharacters; this.trimType = trimType; }
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))); }
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))); }