Is there a good way to provide an “auto-increment” style index column (from 1..x) when projecting items using LINQ?
As a basic example, I’m looking for the index column below to go from 1 to the number of items in list.
var items = from s1 in list
select new BrowsingSessionItemModel { Id = s1.Id, Index = 0 };
Iterating through the list would be the easy option but I was wondering if there was a better way to do this?
You can’t do this with LINQ expressions. You could use the following
.Selectextension method though: