1

LINQ 中是否有 SQL Server PARTITION OVER 功能的等效项?

SELECT Decision_ID ,
       ID
       ROW_NUMBER() OVER ( PARTITION BY Decision_ID 
                           ORDER BY Decision_ID, ID ASC ) calcAmend
FROM   dbo.Decision_Data

它给出了每条记录的排名

4

1 回答 1

2
DecisionData
    .GroupBy(d => d.DecisionID,
        (key, dd) => dd
                     .OrderBy(d => d.Id)
                     .Select((d, i) => new {d.DecisionId, d.Id, calcAmend = i}))
    .SelectMany(d => d)
于 2012-07-25T10:38:42.830 回答