public static StringExpression RTrim(this StringExpression expr) { var newExpr = (StringExpression)expr.Clone(); newExpr._sql = "RTRIM(" + expr._sql + ")"; return(newExpr); }
/// <summary> /// Left of current string expression. /// </summary> /// <param name="expr">The expr.</param> /// <param name="length">The length.</param> /// <returns></returns> public static StringExpression Left(this StringExpression expr, int length) { var newExpr = (StringExpression)expr.Clone(); newExpr.Sql = "LEFT(" + newExpr.Sql + ", ?)"; newExpr.ChildExpressions.Add(new Int32ParameterExpression(length)); return(newExpr); }
public static StringExpression Right(this StringExpression expr, int length) { var newExpr = (StringExpression)expr.Clone(); newExpr._sql = "RIGHT(" + newExpr._sql + ", ?)"; newExpr._childExpressions.Add(new Int32ParameterExpression(length)); return(newExpr); }
public static StringExpression Substring(this StringExpression expr, int begin, int length) { var newExpr = (StringExpression)expr.Clone(); newExpr._sql = "SUBSTRING(" + newExpr._sql + ", ? + 1, ?)"; newExpr._childExpressions.Add(new Int32ParameterExpression(begin)); newExpr._childExpressions.Add(new Int32ParameterExpression(length)); return(newExpr); }
public static Condition StartsWith(this StringExpression expr, StringExpression value) { if (ReferenceEquals(value, null)) { throw new ArgumentNullException("value"); } var escapedLikeValue = (StringExpression)value.Clone(); escapedLikeValue._sql = escapedLikeValue._sql + " + '%'"; return(new Condition(expr, ExpressionOperator.Like, escapedLikeValue)); }
public static StringExpression Right(this StringExpression expr, Int32Expression length) { if (ReferenceEquals(length, null)) { throw new ArgumentNullException("length"); } var newExpr = (StringExpression)expr.Clone(); newExpr._sql = "RIGHT(" + newExpr._sql + ", ?)"; newExpr._childExpressions.Add(length); return(newExpr); }
public static StringExpression Substring(this StringExpression expr, int begin, Int32Expression length) { if (ReferenceEquals(length, null)) { throw new ArgumentNullException("length"); } var newExpr = (StringExpression)expr.Clone(); newExpr._sql = "SUBSTRING(" + newExpr._sql + ", ? + 1, ?)"; newExpr._childExpressions.Add(new Int32ParameterExpression(begin)); newExpr._childExpressions.Add(length); return(newExpr); }
/// <summary> /// Substring of specified expr. /// </summary> /// <param name="expr">The expr.</param> /// <param name="begin">The begin.</param> /// <param name="length">The length.</param> /// <returns></returns> public static StringExpression Substring(this StringExpression expr, Int32Expression begin, int length) { if (ReferenceEquals(begin, null)) { throw new ArgumentNullException("begin"); } var newExpr = (StringExpression)expr.Clone(); newExpr.Sql = "SUBSTR(" + newExpr.Sql + ", ? + 1, ?)"; newExpr.ChildExpressions.Add(begin); newExpr.ChildExpressions.Add(new Int32ParameterExpression(length)); return(newExpr); }
public static StringExpression Replace(this StringExpression expr, StringExpression find, StringExpression replace) { if (ReferenceEquals(find, null)) { throw new ArgumentNullException("find"); } if (ReferenceEquals(replace, null)) { throw new ArgumentNullException("replace"); } var newExpr = (StringExpression)expr.Clone(); newExpr._sql = "REPLACE(" + newExpr._sql + ", ?, ?)"; newExpr._childExpressions.Add(find); newExpr._childExpressions.Add(replace); return(newExpr); }
public static StringExpression Replace(this StringExpression expr, string find, StringExpression replace) { if (string.IsNullOrEmpty(find)) { throw new ArgumentNullException("find"); } if (ReferenceEquals(replace, null)) { throw new ArgumentNullException("replace"); } var newExpr = (StringExpression)expr.Clone(); newExpr._sql = "REPLACE(" + newExpr._sql + ", ?, ?)"; newExpr._childExpressions.Add(new StringParameterExpression(find, expr.IsUnicode)); newExpr._childExpressions.Add(replace); return(newExpr); }
public static Int32Expression GetLength(this StringExpression expr) { return(new Int32Expression("LEN(" + expr._sql + ")", ((StringExpression)expr.Clone())._childExpressions)); }
public static Int32Expression ToUnicode(this StringExpression expr) { return(new Int32Expression("UNICODE(" + expr._sql + ")", ((StringExpression)expr.Clone())._childExpressions)); }
public static Int32Expression ToAscii(this StringExpression expr) { return(new Int32Expression("ASCII(" + expr._sql + ")", ((StringExpression)expr.Clone())._childExpressions)); }
public static Int32Expression IndexOf(this StringExpression expr, StringExpression value) { var newExpr = new Int32Expression("CHARINDEX(?, " + expr._sql + ") - 1", ((StringExpression)expr.Clone())._childExpressions); newExpr.ChildExpressions.Insert(0, value); return(newExpr); }
public static Int32Expression IndexOf(this StringExpression expr, string value) { var newExpr = new Int32Expression("CHARINDEX(?, " + expr._sql + ") - 1", ((StringExpression)expr.Clone())._childExpressions); newExpr.ChildExpressions.Insert(0, new StringParameterExpression(value, expr.IsUnicode)); return(newExpr); }
/// <summary> /// Index of specified substring in current string expression. /// </summary> /// <param name="expr">The expr.</param> /// <param name="value">The substring value.</param> /// <returns></returns> public static Int32Expression IndexOf(this StringExpression expr, StringExpression value) { var newExpr = new Int32Expression("INSTR(" + expr.Sql + ", ?) - 1", ((StringExpression)expr.Clone()).ChildExpressions); newExpr.ChildExpressions.Insert(0, value); return(newExpr); }