I tried to translate
select *
from (
select *, rng = row_number() over (partition by grp order by id)
from (
select *, grp = row_number() over (order by id) - row_number() over (partition by Name, Status, DateFinished order by id)
from tooling ) g
) gn
where rng = 1
order by id
from an earlier question (Grouping with partition and over in TSql)
With help with Row_number over (Partition by xxx) in Linq?
I got the solution to translate ONE of the row_number s but seems I'am out of luck to succesfully translate the entire question?
My attempt:
Tooling.OrderBy( x => x.Id)
.GroupBy( x => new {x.Name,x.Status,x.DateFinished} )
.Select( group => new { Group = group, Count = group.Count() } )
.SelectMany( groupWithCount =>
groupWithCount.Group.Select( b => b)
.Zip(
Enumerable.Range( 1, groupWithCount.Count ),
( j, i ) => new { j.Name,j.Status, j.DateFinished, RowNumber = i }
)
)