I've got the effect I wanted in the end with the following but I just wondered why, as I am iterating over a collection of IPublishedContent so IsLast() should work shouldn't it?
yeah i've tripped up on this a few times, but IsLast() doesn't actually behave the way you (or I have in the past) think it does.
In the background IsLast goes of and gets all the Siblings of an Item and then checks to see if it's the last item in the list. So IsLast only returns true if the IPublishedContent item is the last one in the 'Content Set' which most of the time is the Siblings in the content tree.
In my experience you are better off calling .ToList() at the end of the query and then using the List .Last() like you have
IsLast() IsNotWorking?
Umb 7.7.6
More curiosity than anything, but why doesn't IsLast() work in this scenario......
I've got the effect I wanted in the end with the following but I just wondered why, as I am iterating over a collection of IPublishedContent so IsLast() should work shouldn't it?
--Craig
HI,
yeah i've tripped up on this a few times, but
IsLast()
doesn't actually behave the way you (or I have in the past) think it does.In the background
IsLast
goes of and gets all the Siblings of an Item and then checks to see if it's the last item in the list. So IsLast only returns true if theIPublishedContent
item is the last one in the 'Content Set' which most of the time is the Siblings in the content tree.In my experience you are better off calling
.ToList()
at the end of the query and then using the List.Last()
like you haveis working on a reply...