Last active
December 23, 2015 04:49
-
-
Save zpqrtbnk/6582377 to your computer and use it in GitHub Desktop.
Demo usage of ToContentSet()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// IPublishedContent implements IsFirst, IsOdd, Index and various stuff | |
// so technically it's possible to do | |
@foreach(var content in contents) | |
{ | |
<div class="@(content.IsFirst() ? "first" : "") @(content.IsOdd() ? "odd" : "even")" id="item-@(content.Index())"> | |
@content.Name | |
</div> | |
} | |
// however, because of some issues in IPublishedContent, IsFirst, IsOdd, Index... all | |
// gave random results as soon as contents was not the origin children collection. | |
// this has been fixed but requires the usage of the .ToContentSet() method: | |
var contents = Model | |
.Children() | |
.Where(x => x.GetPropertyValue<int>("whatever") > 10) | |
.OrderBy(x => x.Name) | |
.ToContentSet(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment