我怎样才能将Linq查询返回到Episerver PageDataCollection?我无法在网上找到任何相关信息。
//This becomes IEnumerable<DataPapge> i need it to be PageDataCollection
var banners = DataFactory.Instance
.GetChildren(CurrentPageLink)
.Where(child => child.PageTypeName == "SomeName") ;
//BannerCollection becomse null
PageDataCollection bannerCollection = banners as PageDataCollection;
答案 0 :(得分:5)
将构造函数与ICollection<PageData>
:
PageDataCollection bannerCollection = new PageDataCollection(banners.ToList());
(见source)
或者更好的是其他构造函数采用IEnumerable
:
PageDataCollection bannerCollection = new PageDataCollection(banners);