views:

95

answers:

1

I have

[Person]
PersonID, EmailAddress, FirstName, LastName

[OnlineAccount]
OnlineAccountID, PersonID, Nickname

Each person is allowed to have 0-* OnlineAccount.

In entity framework with C#, how do I select the top 5 Person that has the most accounts?

+6  A: 

Try this:

context.PersonSet.OrderByDescending(u => u.OnlineAccounts.Count).Take(5);
LukLed