Daa*_*win 2 linq ienumerable episerver
我如何才能将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;
Run Code Online (Sandbox Code Playgroud)
使用构造函数ICollection<PageData>:
PageDataCollection bannerCollection = new PageDataCollection(banners.ToList());
Run Code Online (Sandbox Code Playgroud)
(在来源中找到)
或者更好的是其他构造函数采取IEnumerable:
PageDataCollection bannerCollection = new PageDataCollection(banners);
Run Code Online (Sandbox Code Playgroud)