public static List <ModeChannel> MySelectByParentID(int ParentID)
    {
        List <ModeChannel> channelData = new List <ModeChannel>();
        List <int>         idList      = new List <int>();

        //查询数据
        ModeChannel value    = new ModeChannel();
        ModeChannel conditon = new ModeChannel();

        if (ParentID > 0)
        {
            conditon.Path = "%~" + ParentID + "~%";
            conditon.AddAttach("Path", "like");
        }

        List <ModeChannel> oldTypeData = TableOperate <ModeChannel> .Select(value, conditon, 0, " order by ParentID, Depth, OrderID DESC, ID DESC ");

        for (int i = 0; i < oldTypeData.Count; i++)
        {
            ModeChannel typeObj = oldTypeData[i];
            if (typeObj.Depth == 0) //深度为0,直接添加
            {
                channelData.Insert(0, typeObj);
                idList.Insert(0, typeObj.ID);
            }
            else
            {
                int pArentIndex = idList.IndexOf(typeObj.ParentID); //查找上及目录所在位置!
                channelData.Insert(pArentIndex + 1, typeObj);
                idList.Insert(pArentIndex + 1, typeObj.ID);         //将数据插入上级目录之后
            }
        }
        return(channelData);
    }
    /// <summary>
    /// 获取所有子类id序列,例如 1,3,4,5,6
    /// </summary>
    /// <param name="id">要查询频道的id</param>
    /// <returns></returns>
    public static string GetChildID(int id)
    {
        ModeChannel value = new ModeChannel();

        value.ID = 0;
        ModeChannel conditon = new ModeChannel();

        conditon.Path = "%~" + id + "~%";
        conditon.AddAttach("Path", "like");
        if (AdminMethod.ExhibitionID != 0)
        {
            conditon.ExhibitionID = AdminMethod.ExhibitionID;
        }
        List <ModeChannel> childChannelList = TableOperate <ModeChannel> .Select(value, conditon);

        string idStr = "";

        for (int i = 0; i < childChannelList.Count; i++)
        {
            idStr += childChannelList[i].ID + ",";
        }

        idStr = idStr.Trim(',');
        return(idStr);
    }
    private static int UpdateChild(ModeChannel channel, ModeChannel oldChannel)
    {
        //int depthSpan = channel.Depth - oldChannel.Depth;
        ModeChannel value     = new ModeChannel();
        ModeChannel condition = new ModeChannel();

        condition.Path = "%~" + channel.ID + "~%";
        condition.AddAttach("Path", "like");

        value.RootID = channel.RootID;
        value.Depth  = channel.Depth - oldChannel.Depth;
        value.AddParameter("OldPath", oldChannel.Path + "" + channel.ID + "~");
        value.AddParameter("OldNamePath", oldChannel.NamePath + "" + oldChannel.Name + "~");
        value.Path     = channel.Path + "" + channel.ID + "~";
        value.NamePath = channel.NamePath + "" + channel.Name + "~";

        value.SetUpdate(" RootID=@RootID, Depth = Depth + @Depth, [Path]=REPLACE([Path], @OldPath, @Path) , [NamePath]=REPLACE([NamePath], @OldNamePath, @NamePath)");
        return(TableOperate <ModeChannel> .Update(value, condition));
    }