예제 #1
0
        /// <summary>
        /// 更新父级Id实例事务时候新建索引。
        /// </summary>
        /// <typeparam name="TParentIndex">索引类型。</typeparam>
        /// <param name="db">数据库事务操作接口实例。</param>
        /// <param name="id">当前实例Id。</param>
        /// <param name="parentId">父级Id。</param>
        /// <param name="cancellationToken">取消标志。</param>
        /// <returns>返回添加结果。</returns>
        public static async Task <bool> UpdateIndexAsync <TParentIndex>(this IDbTransactionContext <TParentIndex> db, int id, int parentId, CancellationToken cancellationToken = default)
            where TParentIndex : IParentIndex, new()
        {
            await db.DeleteAsync(x => x.Id == id, cancellationToken);//删除原有的父级ID

            return(await db.CreateIndexAsync(id, parentId, cancellationToken));
        }