コード例 #1
0
        public static DateTimeExpression AddYear(this DateTimeExpression expr, int n)
        {
            var newExpr = (DateTimeExpression)expr.Clone();

            newExpr._sql = "DATEADD(year, ?, " + newExpr._sql + ")";
            newExpr._childExpressions.Insert(0, new Int32ParameterExpression(n));

            return(newExpr);
        }
コード例 #2
0
        public static DateTimeExpression AddMonth(this DateTimeExpression expr, int n)
        {
            var newExpr = (DateTimeExpression)expr.Clone();

            newExpr._sql = "ADD_MONTHS(month, ?, " + newExpr._sql + ")";
            newExpr._childExpressions.Insert(0, new Int32ParameterExpression(n));

            return(newExpr);
        }
コード例 #3
0
        /// <summary>
        /// Add seconds to current datetime expression.
        /// </summary>
        /// <param name="expr">The expr.</param>
        /// <param name="n">The number of seconds.</param>
        /// <returns></returns>
        public static DateTimeExpression AddSecond(this DateTimeExpression expr, int n)
        {
            var newExpr = (DateTimeExpression)expr.Clone();

            newExpr.Sql = "DATEADD(second, ?, " + newExpr.Sql + ")";
            newExpr.ChildExpressions.Insert(0, new Int32ParameterExpression(n));

            return(newExpr);
        }
コード例 #4
0
        public static DateTimeExpression AddMonth(this DateTimeExpression expr, Int32Expression n)
        {
            if (n == null)
            {
                throw new ArgumentNullException("n");
            }

            var newExpr = (DateTimeExpression)expr.Clone();

            newExpr._sql = "DATEADD(month, ?, " + newExpr._sql + ")";
            newExpr._childExpressions.Insert(0, n);

            return(newExpr);
        }
コード例 #5
0
 public static Int32Expression GetSecond(this DateTimeExpression expr)
 {
     return(new Int32Expression("DATEPART(second, " + expr._sql + ")", ((DateTimeExpression)expr.Clone())._childExpressions));
 }
コード例 #6
0
 /// <summary>
 /// Gets the minute.
 /// </summary>
 /// <param name="expr">The expr.</param>
 /// <returns></returns>
 public static Int32Expression GetMinute(this DateTimeExpression expr)
 {
     return(new Int32Expression("DATEPART(minute, " + expr.Sql + ")", ((DateTimeExpression)expr.Clone()).ChildExpressions));
 }