how to write this sql in efcore?

mc 6,396 Reputation points
2022-08-12T06:27:26.377+00:00
select rank() over(partition by e.Id, e.CreateTime order by  e.score desc) id from ScoreInfo  

how to write it in ef core?

Developer technologies | .NET | Entity Framework Core
{count} votes

1 answer

Sort by: Most helpful
  1. Jack J Jun 25,316 Reputation points
    2022-08-18T08:36:07.337+00:00

    @mc , Welcome to Microsoft Q&A, based on my test you could try the following code example to achieve the same function with the sql query you mentioned.

    code.txt

    We need to use GroupBy and SelectMany method to do it.

    Result:

    232278-image.png

    Hope this could help you.

    Best Regards,
    Jack


    If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.