Skip to main content

AddToAny

Share/Save

RowNumber Alternative in Linq

2 replies [Last post]
ranjit
ranjit's picture
User offline. Last seen 2 years 23 weeks ago. Offline
Joined: 08/26/2009

I want to know, Do we have any alternative to Row_Number function in Linq. I want to use Ranking and Partition in Linq.

 

SELECT ROW_NUMBER() OVER(Partition BY Author_Name

Please let me know how to achieve the same functionality in Linq.

Anonymous
Anonymous's picture
we can implement row_number()

we can implement row_number() functionality using a integer variable.

INT i=1;
grdLinq.DataSource = Process.GetProcesses()
                  .SELECT(p => NEW { p.ProcessName,p.WorkingSet64,rownumber=i++});

rownumber=i++ will add a new int coloumn.

Anonymous
Anonymous's picture
@Above

You did'nt mention, How to implement Partition by in linq.