Umbraco 无法获取IContent的子级

Umbraco 无法获取IContent的子级,umbraco,umbraco8,Umbraco,Umbraco8,我正在尝试获取Icontent对象的子对象 IContent filialsParent = cs.GetById(filialParrentId); if (filialsParent != null) { IContentService contentService = Umbraco.Core.Composing.Current.Services.ContentService; bool hasChildren = contentService.HasChildren(f

我正在尝试获取
Icontent
对象的
子对象

IContent filialsParent = cs.GetById(filialParrentId);

if (filialsParent != null)
{
    IContentService contentService = Umbraco.Core.Composing.Current.Services.ContentService;
    bool hasChildren = contentService.HasChildren(filialsParent.Id);
    long totalChildren;

    IEnumerable<IContent> children = contentService.GetPagedChildren(filialsParent.Id, 1, 100, out totalChildren);

    foreach (var child in children)
    {
        context.WriteLine(string.Format("child: {0}", child.Name));
    }

    context.WriteLine(string.Format("Children found:({0}) in: {1}", children.Count(), filialParrentId));

}
IContent-filialsParent=cs.GetById(filialParrentId);
if(filialsParent!=null)
{
IContentService contentService=Umbraco.Core.Composing.Current.Services.contentService;
bool haschilds=contentService.haschilds(filialsParent.Id);
长期儿童;
IEnumerable children=contentService.GetPagedChildren(filialsParent.Id,1100,out totalChildren);
foreach(儿童中的儿童变量)
{
WriteLine(string.Format(“child:{0}”,child.Name));
}
WriteLine(string.Format(“在:{1}”、Children.Count()、filialParrentId中找到的子项:({0}));
}
如果我调试代码,我会得到以下结果

My
long totalChildren
将在
contentService.GetPagedChildren(filialsParent.Id,1100,out totalChildren)行后为1运行

My
IEnumerable children
为空,因此(当然)是My
children.Count()
0

遗憾的是,
filialsParent
没有像我希望的那样包含函数
.children()


有没有办法获取我的
filialsParent
的子项,是的,它确实有已发布的子项。

我遇到了完全相同的问题。出于测试目的,我删除了所有内容,只删除了最基本的部分

==>umbraco 8.0.2

确保你有一个父母和几个孩子

// For testing purposes hardcode your parent Id
var contentId = [ID];

// SET for returning total records
long totalChildren;

// int id ==> You even could hardcode your first param (contentID in here)
// long pageIndex ==> SET your index to 0 ==> first indexpage starts at 0 and not 1 ==> if you set this to 1 and the Pagesize = 100  and you have only 99 childeren you wil wil get null because we are requesting the second page
// int pageSize ==> We need max 10 childeren
// out long totalChildren 
// IQuery<IContent> filter = null ==> not used 
// Ordering ordering = null ==> not used
IEnumerable<IContent> children = Services.ContentService.GetPagedChildren(contentId, 0, 10, out totalChildren);
//出于测试目的,对父Id进行硬编码
var contentId=[ID];
//设置为返回总记录
长期儿童;
//int id=>您甚至可以硬编码您的第一个参数(这里的contentID)
//long pageIndex==>将索引设置为0==>第一个indexpage从0开始,而不是1==>如果将此设置为1,Pagesize=100,并且您只有99个孩子,则由于我们请求第二个页面,因此您将得到null
//int pageSize==>我们最多需要10个孩子
//让孩子们出去
//IQuery筛选器=空==>未使用
//排序=空==>未使用
IEnumerable children=Services.ContentService.GetPagedChildren(contentId,0,10,out totalChildren);

我遇到了完全相同的问题。出于测试目的,我删除了所有内容,只删除了最基本的部分

==>umbraco 8.0.2

确保你有一个父母和几个孩子

// For testing purposes hardcode your parent Id
var contentId = [ID];

// SET for returning total records
long totalChildren;

// int id ==> You even could hardcode your first param (contentID in here)
// long pageIndex ==> SET your index to 0 ==> first indexpage starts at 0 and not 1 ==> if you set this to 1 and the Pagesize = 100  and you have only 99 childeren you wil wil get null because we are requesting the second page
// int pageSize ==> We need max 10 childeren
// out long totalChildren 
// IQuery<IContent> filter = null ==> not used 
// Ordering ordering = null ==> not used
IEnumerable<IContent> children = Services.ContentService.GetPagedChildren(contentId, 0, 10, out totalChildren);
//出于测试目的,对父Id进行硬编码
var contentId=[ID];
//设置为返回总记录
长期儿童;
//int id=>您甚至可以硬编码您的第一个参数(这里的contentID)
//long pageIndex==>将索引设置为0==>第一个indexpage从0开始,而不是1==>如果将此设置为1,Pagesize=100,并且您只有99个孩子,则由于我们请求第二个页面,因此您将得到null
//int pageSize==>我们最多需要10个孩子
//让孩子们出去
//IQuery筛选器=空==>未使用
//排序=空==>未使用
IEnumerable children=Services.ContentService.GetPagedChildren(contentId,0,10,out totalChildren);