find users that are following other users

Posted by Jakob on Stack Overflow See other posts from Stack Overflow or by Jakob
Published on 2010-05-24T16:03:21Z Indexed on 2010/05/24 16:31 UTC
Read the original article Hit count: 170

Filed under:
|

Hi I'm wondering how I can go about this problem

I have a DB with a Users Table, and a Followers table. The Followers table contains 2 Columns "FollowerID" and "FollowedID" I have a 1 -> * relation in my datamodel between Users.ID -> Followers.FollowerID and Users.ID -> FollowedID

How do I in LINQ get a set of users that are following a specific user?

I'll express what I'm trying to achieve programatically I can get this far:

ctx.Followers.Where(f => f.FollowedID == CurrentUser.ID)

so now i have a Followers set where I have the ID of the users that follow the CurrentUser, and I could iterate through this collection and then add users after each iteration to a collection that would be a total USER collection that followed CurrentUser, but isn't there a smarter, or LINQ'er way to do this?

Much appreciated

Thx

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ