/// <summary>
 /// 添加实例事务时候新建索引。
 /// </summary>
 /// <typeparam name="TParentIndex">索引类型。</typeparam>
 /// <param name="db">数据库事务操作接口实例。</param>
 /// <param name="id">当前实例Id。</param>
 /// <param name="parentId">父级Id。</param>
 /// <returns>返回添加结果。</returns>
 public static bool CreateIndex <TParentIndex>(this IDbTransactionContext <TParentIndex> db, int id, int parentId)
     where TParentIndex : IParentIndex, new()
 {
     //最顶级无需更新
     if (parentId <= 0)
     {
         return(true);
     }
     db.ExecuteNonQuery($@"INSERT INTO {db.EntityType.Table}(ParentId, Id) SELECT ParentId, {id} FROM {db.EntityType.Table} WITH(NOLOCK) WHERE Id = {parentId};");
     return(db.Create(new TParentIndex {
         Id = id, ParentId = parentId
     }));
 }