I'm not a LINQ expert but I've been messing with it a lot lately so I'll 
give it a shot.  What your current query says is, "for each user in 
_currentUser.Leaders (the outer IEnumerable), give me a list of their 
reviews (the inner IList)."  You just need to go down one more level.

var reviews = from user in _currentUser.Leaders
                   from review in user.Reviews
                   where review.postDate >= DateTime.Now.AddMonths(-3)
                   select review;

Joseph is right about SelectMany if you want to use the other syntax.  
SelectMany will 'flatten' all the review collections into a single 
collection.

var reviews = _currentUser.Leaders.SelectMany(l => l.Reviews).Where(r => 
r.postDate >= DateTime.Now.AddMonths(-3));

I don't have Visual Studio in front of me right now so I can't check any of 
that, but it should be close.

-Patrick

On Wednesday, March 21, 2012 2:48:01 PM UTC-5, feelexit wrote:
>
> I have 3 tables. 
>
> Users table  (Id, name, emal) 
> Reviews table (Id, title, body, postDate) 
> Following table (leader, Follower) : both leader and follower are 
> UserId,  you can follow other users, you will are someone's follower, 
> you can see their last 3 month reviews. 
>
> I try to get all the reviews that your leaders posted in hte last 3 
> month. 
>
>  var reviews = from user in _currentUser.Leaders 
>                           select user.Reviews; 
>
> I am getting back a list of Ilist<review>. it is definitely not 
> correct.  please help me out, thank you.

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/nhusers/-/dnnEIEXnTV0J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to