c# - Anonymous type with counter for each result -
is possible have counter going when creating linq query returning anonymous object?
e.g.
var results = foo in bar select new { foo.id, foo.name, counter = ???? } i tried defining method returns increasing number, end result same objects.
to clarify: want result
id, name, 1
id, name, 2
id, name, 3
etcetera
var counter = 0; var results = foo in bar select new { foo.id, foo.name, counter = ++counter };
Comments
Post a Comment