I think I’ve mentioend before that I’ve been working on an internal website using ASP.NET and ECO II. Partly because replacing the current site (based on static HTML) is going to make my life a lot easier, but also as I kinda miss coding as a day job, and of course if you want to really learn a new technology like ECO, there’s no substitute for actually building and deploying an app into production.
Anyway, one of the things I wanted to do was to display summary lists of items on the main page of the site. You know, recently posted items, important upcoming dates, last 10 posts to the SE mailing list, etc. Most of this is easy, OCL like the following will pull out all Items in reverse order (ie. most newest to oldest).
Item.allInstances->orderdescending(ModifiedTime)
Problem is, I don’t want to display all Items, only the most recent items, say, the last 10. Enter the subSequence operator:
Item.allInstances->orderdescending(ModifiedTime)->subSequence(1,10)
With this, I have a list of 10 Items, starting at position 1 in my list of Items ordered by ModifiedTime. Perfect!
Be the first to leave a comment. Don’t be shy.