views:

151

answers:

2

Hello all, It has been a while since I have wrote any code due to military obligations (Afghanistan, Reserves) and I have a question with regard to linq 2 sql (hell, I would do this as a stored proc at this point...I really am rusty).

I have a table of feed names, and those feeds have subscribers in another table (foreign key association and all that jazz). What is the Linq code to find the top five feeds? In sql I am thinking something like

select top(5) from tblFeeds f
inner join tblSubscribers s 
on f.id = s.FeedId
order by descending

The above code is probably completely wrong, but I hope you can gather my intent. I am trying to do this in a Linq2Sql type of structure. Any help?

A: 

Look at the Take and Skip functions. They will be translated to SQL too :)

leppie
+2  A: 
var feeds = (
   from f in myContext.tblFeeds
   order by f.Subscribers.Count() descending
   select f
   ).Take(5);

Assuming you want top feeds based on amount of subscribers :)

eglasius