Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在子ViewModel中从IList获取数据_C#_Asp.net_Asp.net Mvc - Fatal编程技术网

C# 在子ViewModel中从IList获取数据

C# 在子ViewModel中从IList获取数据,c#,asp.net,asp.net-mvc,C#,Asp.net,Asp.net Mvc,我试图迭代来自父控制器的子对象集合 public class ListBlogsPageModel : IPageViewModel<ListBlogsPage> { public IList<BlogPage> BlogPages { get; set; } } public class BlogPageModel : IPageViewModel<BlogPage> { public IList<ProfilePage>

我试图迭代来自父控制器的子对象集合

 public class ListBlogsPageModel : IPageViewModel<ListBlogsPage>
 {
     public IList<BlogPage> BlogPages { get; set; }
 }
public class BlogPageModel : IPageViewModel<BlogPage>
{
    public IList<ProfilePage> Profiles { get; set; }
}
公共类ListBlogsPageModel:IPageViewModel
{
公共IList博客页面{get;set;}
}
BlogPage包含BlogPage的索引。这个BlogPage模型包含我想在父控制器中迭代的ProfilePage的IList

 public class ListBlogsPageModel : IPageViewModel<ListBlogsPage>
 {
     public IList<BlogPage> BlogPages { get; set; }
 }
public class BlogPageModel : IPageViewModel<BlogPage>
{
    public IList<ProfilePage> Profiles { get; set; }
}
公共类BlogPageModel:IPageViewModel
{
公共IList配置文件{get;set;}
}
现在我的问题是如何在父ListBlogsPage中访问这个子概要文件模型?我已经尝试过以与我已经获得BlogPage儿童(见下文)相同的方式获得个人资料,但我似乎没有收到任何价值

public ActionResult Index(ListBlogsPage currentPage)
{
    var model = new ListBlogsPageModel(currentPage);
    var blogPages = _contentLoader.GetChildren<BlogPage>(currentPage.ContentLink).ToList();
    var authorPages = _contentLoader.GetChildren<ProfilePage>(currentPage.ContentLink).ToList();
    var filteredPages = _contentFilterService.FilterForDisplay(blogPages, false, true).ToList();
    var filteredAuthors = _contentFilterService.FilterForDisplay(authorPages, false, true).ToList();
    model.BlogPages = filteredPages;
    model.AuthorPages = filteredAuthors;
    return View(model);
}
公共操作结果索引(ListBlogsPage当前页面) { var模型=新的ListBlogsPageModel(currentPage); var blogPages=_contentLoader.getchildrentpage.ContentLink.ToList(); var authorPages=_contentLoader.getchildrent(currentPage.ContentLink.ToList(); var filteredPages=\u contentFilterService.FilterForDisplay(blogPages,false,true).ToList(); var filteredAuthors=\u contentFilterService.FilterForDisplay(authorPages,false,true).ToList(); model.BlogPages=filteredpage; model.AuthorPages=filteredAuthors; 返回视图(模型); }
我可能错了,但好像是你问的。

谢谢!这段代码是针对索引控制器的吗?或者它是用来渲染一个带有轮廓的视图?它可以在任何地方使用,但在这种情况下用于控制器。