コード例 #1
0
 /// <summary>
 /// Adds a NOT condition to the update statement.
 /// </summary>
 /// <param name="update">The update statement.</param>
 /// <param name="columnName">Name of the column.</param>
 /// <param name="op">The op.</param>
 /// <param name="value">The value.</param>
 /// <returns>The update statement.</returns>
 public static UpdateStatement WhereNot(this UpdateStatement update, string columnName, SqlOperator op, object value)
 {
     update.Conditions.Add(new Condition(columnName, op, value)
     {
         Not = true
     });
     return(update);
 }
コード例 #2
0
 /// <summary>
 /// Adds an OR condition to the update statement.
 /// </summary>
 /// <param name="update">The update statement.</param>
 /// <param name="columnName">Name of the column.</param>
 /// <param name="op">The op.</param>
 /// <param name="value">The value.</param>
 /// <returns>The update statement.</returns>
 public static UpdateStatement Or(this UpdateStatement update, string columnName, SqlOperator op, object value)
 {
     update.Conditions.Add(new Condition(columnName, op, value)
     {
         Relationship = ConditionRelationship.Or
     });
     return(update);
 }
コード例 #3
0
        /// <summary>
        /// Adds an OR condition to the update statement.
        /// </summary>
        /// <typeparam name="T">The type corresponding to the table that records should be updated in.</typeparam>
        /// <param name="update">The update.</param>
        /// <param name="condition">The condition.</param>
        /// <returns>The update statement.</returns>
        public static UpdateStatement <T> Or <T>(this UpdateStatement <T> update, Expression <Func <T, bool> > condition)
        {
            var combined = update.Conditions.Body.OrElse(condition.Body);

            combined          = AnonymousParameterReplacer.Replace(combined, condition.Parameters);
            update.Conditions = Expression.Lambda <Func <T, bool> >(combined, condition.Parameters);
            return(update);
        }
コード例 #4
0
 /// <summary>
 /// Adds a condition to the update statement.
 /// </summary>
 /// <param name="update">The update statement.</param>
 /// <param name="all">if set to <c>true</c> [all].</param>
 /// <returns>The update statement.</returns>
 public static UpdateStatement Where(this UpdateStatement update, bool all)
 {
     if (all)
     {
         var newCondition = new Condition();
         newCondition.Field = new ConstantPart(true);
         newCondition.Value = new ConstantPart(true);
         update.Conditions.Add(newCondition);
     }
     return(update);
 }
コード例 #5
0
        public UpdateStatement CreateStatement(DatabaseMapper mapper)
        {
            var update = new UpdateStatement();

            update.Target = new Table(mapper.GetTableName(this.Target));
            update.SetValues.AddRange(this.SetValues.Select(sv => new SetValue(new Column(mapper.GetTableName(sv.Item1.DeclaringType), mapper.GetColumnName(sv.Item1)), sv.Item2)));
            foreach (var condition in StatementCreator.VisitStatementConditions(this.Conditions, mapper, false))
            {
                update.Conditions.Add(condition);
            }
            return(update);
        }
コード例 #6
0
        public override Statement CreateStatement(DatabaseMapper mapper)
        {
            var update = new UpdateStatement();

            update.Target = new Table(mapper.GetTableName(this.Target));
            update.SetValues.AddRange(this.SetValues.Select(sv => PropertyToSetValue(sv, mapper)));
            foreach (var condition in StatementCreator.VisitStatementConditions(this.Conditions, mapper, false))
            {
                update.Conditions.Add(condition);
            }
            return(update);
        }
コード例 #7
0
 /// <summary>
 /// Adds a value to set with the statement.
 /// </summary>
 /// <param name="update">The update statement.</param>
 /// <param name="columnName">Name of the column.</param>
 /// <param name="value">The value.</param>
 /// <returns>The update statement.</returns>
 public static UpdateStatement Set(this UpdateStatement update, string columnName, object value)
 {
     update.SetValues.Add(new SetValue(columnName, value));
     return(update);
 }
コード例 #8
0
 /// <summary>
 /// Adds a condition to the update statement.
 /// </summary>
 /// <typeparam name="T">The type corresponding to the table that records should be updated in.</typeparam>
 /// <param name="update">The update.</param>
 /// <param name="condition">The condition.</param>
 /// <returns>The update statement.</returns>
 public static UpdateStatement <T> Where <T>(this UpdateStatement <T> update, Expression <Func <T, bool> > condition)
 {
     update.Conditions = condition;
     return(update);
 }
コード例 #9
0
 /// <summary>
 /// Adds a value to set with the statement.
 /// </summary>
 /// <typeparam name="T">The type corresponding to the table that records should be updated in.</typeparam>
 /// <param name="update">The update.</param>
 /// <param name="property">The property.</param>
 /// <param name="value">The value.</param>
 /// <returns>The update statement.</returns>
 public static UpdateStatement <T> Set <T>(this UpdateStatement <T> update, Expression <Func <T, object> > property, object value)
 {
     update.SetValues.Add(new FieldValue(FuncToPropertyInfo(property), value));
     return(update);
 }