Beispiel #1
0
        /// <summary>
        /// 添加新的Sql删除语句类
        /// </summary>
        /// <param name="action">待执行的语句</param>
        /// <returns>当前集合</returns>
        /// <example>
        /// <code lang="C#">
        /// <![CDATA[
        /// public class ProductRepository : AbstractDatabaseTable<Product>
        /// {
        ///     //other necessary code
        ///
        ///     public Boolean AddEntity(Product product)
        ///     {
        ///         return this.Sequence()
        ///             .Delete(d => d.Where(c => c.Equal(PRODUCTID, product.ID)))
        ///             .Insert(i => i.Set(PRODUCTID, product.ID).Set(PRODUCTNAME, product.Name))
        ///             .Result();
        ///     }
        /// }
        /// ]]>
        /// </code>
        /// </example>
        public CommandCollection Delete(Action <DeleteCommand> action)
        {
            DeleteCommand command = this._database.CreateDeleteCommand(this.TableName);

            this._list.Add(command);
            action(command);

            return(this);
        }
Beispiel #2
0
        /// <summary>
        /// 当添加指定Sql删除语句类
        /// </summary>
        /// <param name="where">查询语句</param>
        /// <returns>当前集合</returns>
        public CommandCollection Delete(Func <SqlConditionBuilder, ISqlCondition> where)
        {
            DeleteCommand command = this._database.CreateDeleteCommand(this.TableName);

            command.Where(where (command.ConditionBuilder));

            this._list.Add(command);

            return(this);
        }
Beispiel #3
0
        /// <summary>
        /// 当满足指定条件时添加指定Sql删除语句类
        /// </summary>
        /// <param name="condition">指定条件</param>
        /// <param name="action">待执行的语句</param>
        /// <returns>当前集合</returns>
        public CommandCollection Delete(Func <Boolean> condition, Action <DeleteCommand> action)
        {
            if (condition())
            {
                DeleteCommand command = this._database.CreateDeleteCommand(this.TableName);
                this._list.Add(command);

                action(command);
            }

            return(this);
        }