Get Sitecore Items sorted by created date

In this article we will learn how to sort sitecore items by creation date.

suppose you want to get items which created recently then you can set sort order in your c# code and get latest items.

you have to just add single line of code to achieve.


 Sitecore.Data.Database current = Sitecore.Context.Database;
 Item getItem = current.GetItem(pass your folder id); 

 IEnumerable<Item> allItems = getItem.GetChildren().OrderByDescending(sort => sort.Created)  




you can put where condition to filter items for specific field. means you can manage code according to your requirement..



Happy Coding😊

Comments

Popular posts from this blog

Difference between shared, Versioned and Unversioned fileds in sitecore

How to find broken links in Sitecore.

Setup First Sitecore Helix Example From Scratch (Blank solution)