Today I needed to add an special field to my LINQ query. A kind of Row Number column. Actually it was not a row number nor was it a column since LINQ deals with objects, but since it was used for presenting data in a tabular way, I see no other name that fits the description.
So, I needed a data displayed in a following format:
First column had to be generated somehow. Using LINQ. I made few quick searches on google, but whith no success, so I came out with my own solution:
int i = 1; return from author in DataContext.Authors select new Author() { Lp = i++, Name = author.Name };
So very simple. Isn't it?
Remember Me
a@href@title, strike
Powered by: newtelligence dasBlog 2.0.7226.0
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2008, Michal Talaga
E-mail