/// <summary>
        /// 异步执行一个移除的命令模型。
        /// </summary>
        /// <typeparam name="TEntity">实体的数据类型。</typeparam>
        /// <param name="bus">命令总线。</param>
        /// <param name="entityOrPKValues">实体的实例对象,在删除命令中 <paramref name="entityOrPKValues"/> 可以是主键的值(表只有一个主键,值允许是一个数组,表示删除多条记录),也可以是匿名对象的部分成员(<paramref name="entityOrPKValues"/> 属性成员和 <typeparamref name="TEntity"/> 属性成员必须一致)。</param>
        /// <param name="tunnel">用于个性化表名和命令的暗道,可以为 null 值。</param>
        /// <returns>受影响的行。</returns>
        public static Task <int> RemoveAnonymousAsync <TEntity>(this ICommandBus bus, object entityOrPKValues, ICommandTunnel tunnel = null)
        {
            if (bus == null)
            {
                throw new ArgumentNullException(nameof(bus));
            }

            return(Filter(bus, DbExtensions.GetRemoveWhere <TEntity>(bus.GetDbEngine(), entityOrPKValues)).RemoveAsync <TEntity>(tunnel));
        }
 /// <summary>
 /// 异步执行一个修改的命令模型。
 /// </summary>
 /// <typeparam name="TEntity">实体的数据类型。</typeparam>
 /// <param name="bus">命令总线。</param>
 /// <param name="entity">实体的实例。</param>
 /// <param name="tunnel">用于个性化表名和命令的暗道,可以为 null 值。</param>
 /// <returns>受影响的行。</returns>
 public static Task <int> ModifyAnonymousAsync <TEntity>(this ICommandBus bus, object entity, ICommandTunnel tunnel = null)
 => Filter(bus, DbExtensions.GetModifyKeyValues <TEntity>(entity)).ModifyAsync <TEntity>(entity, tunnel);
 /// <summary>
 /// 异步执行一个查询主键是否存在的命令模型。
 /// </summary>
 /// <typeparam name="TEntity">实体的数据类型。</typeparam>
 /// <param name="bus">命令总线。</param>
 /// <param name="keyName">主键的列名。</param>
 /// <param name="keyValue">主键的列值。</param>
 /// <param name="tunnel">用于个性化表名和命令的暗道,可以为 null 值。</param>
 /// <returns>表示数据是否存在。</returns>
 public static Task <bool> ExistsAsync <TEntity>(this ICommandBus bus, string keyName, object keyValue, ICommandTunnel tunnel = null)
 => Filter(bus, DbExtensions.GetKeyValues <TEntity>(keyName, keyValue)).ExistsAsync <TEntity>(tunnel);
 /// <summary>
 /// 异步执行一个查找单项的命令模型。
 /// </summary>
 /// <typeparam name="TEntity">实体的数据类型。</typeparam>
 /// <typeparam name="TView">视图的数据类型。</typeparam>
 /// <param name="bus">命令总线。</param>
 /// <param name="keyName">主键的列名。可以为 null 值。</param>
 /// <param name="keyValue">主键的列值。</param>
 /// <param name="select">视图选择器。可以为 null 值,表示不采用匿名对象的方式。</param>
 /// <param name="tunnel">用于个性化表名和命令的暗道,可以为 null 值。</param>
 /// <returns>实体。</returns>
 public static Task <TView> FindOneAsync <TEntity, TView>(this ICommandBus bus, string keyName, object keyValue, Func <TEntity, TView> select, ICommandTunnel tunnel = null)
 => Filter(bus, DbExtensions.GetKeyValues <TEntity>(keyName, keyValue)).FindOneAsync(select, tunnel);
Example #5
0
 /// <summary>
 /// 创建一个筛选执行器。
 /// </summary>
 /// <param name="bus">命令总线。</param>
 /// <param name="ps">参数集合实例。</param>
 /// <param name="binary">二元运算符。</param>
 /// <returns>筛选执行器。</returns>
 public static IFilterExecutor Filter(this ICommandBus bus, ExecuteParameterCollection ps, string binary = "AND")
 => Filter(bus, DbExtensions.CreateWhere(bus.GetDbEngine(), ps, binary), ps);
Example #6
0
 /// <summary>
 /// 执行一个查找单项的命令模型。
 /// </summary>
 /// <typeparam name="TEntity">实体的数据类型。</typeparam>
 /// <typeparam name="TView">视图的数据类型。</typeparam>
 /// <param name="bus">命令总线。</param>
 /// <param name="keyName">主键的列名。可以为 null 值。</param>
 /// <param name="keyValue">主键的列值。</param>
 /// <param name="tunnel">用于个性化表名和命令的暗道,可以为 null 值。</param>
 /// <returns>实体。</returns>
 public static TView FindOne <TEntity, TView>(this ICommandBus bus, string keyName, object keyValue, ICommandTunnel tunnel = null)
 => Filter(bus, DbExtensions.GetKeyValues <TEntity>(keyName, keyValue)).FindOne <TEntity, TView>(tunnel);