I'm trying to grab the last four ImageUrl properties in my razor page for each item in each category.
I have a collection of categories that looks like this:
public class CategoryIndexModel
{
public IEnumerable<CategoryModel> Categories { get; set; }
}
In that collection I have a collection of items as a property in this model:
public class CategoryModel
{
public string CategoryName { get; set; }
public int ListingQty { get; set; }
public int SoldQty { get; set; }
public string Notes { get; set; }
public IEnumerable<InventoryItemModel> Items {get; set;}
}
Each item in the collection has a proeperty title, I want to access the most recently added 4 items and their properties in my view.
@foreach (var item in Model.Categories){
//display item.items[last].title, item.items[last-1].title, item.items[last-2].title
}