Hi,

I'm not quite sure what you mean by return the followers as a projected
result (i'm still working on learning all the terminology).

At the moment by domain is like this:

User
 -> Name
 -> Email (etc...)
 -> Followers (many-to-many users)
 -> Following (many-to-many users)

There is no additional property such as IsFollowingLoggedInUser because that
doesn't seem to fit within my model.

Is this what you are getting at?

Paul

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf
Of Frans Bouma
Sent: 20 July 2010 19:56
To: [email protected]
Subject: RE: [nhusers] Eager loading child collections of many-to-many
problem.

> I have come stuck in optimizing one of my queries...here is my scenario...
> 
> I have a domain similar to Twitter where a user can follow other users. So
> here is a sample of my User model:
> 
> User
>  -> Followers (many-to-many users)
>  -> Following (many-to-many users)
> 
> I now need to return a paged result of following user 'XYZ', but also
eager
> load data needed to determine if the currently logged in user is following
> the returned followers.
> 
> So somehow i need to eager load this: user->followers->following (but at
the
> same time return the list of followers for user 'XYZ')
> 
> Is this even possible to do in 1 query, or will I need to perform 2
separate
> queries? 1 query to return the paged data of followers, then another query
> specifying an IN clause with returned ID's to fetch the following data for
> logged in user.

        User -> Followers isn't the problem, you want for each row returned
a separate (scalar) value which indicates whether user follows any of the
followers returned. How have you modeled this in your model? I ask this as
it's a cumbersome thing to model this, as it's not a static artifact, it's a
projection result, and as that's the case, you could perhaps fetch the
followers as a projection with an additional field 'following' which is
either a scalar query in the projection or a simple id / null due to the
join with following.

                FB


------------------------------------------------------------------------
Lead developer of LLBLGen Pro, .NET's most advanced O/R mapping designer.
LLBLGen Pro website: http://www.llblgen.com
Blog: http://weblogs.asp.net/fbouma
Twitter: http://twitter.com/FransBouma
Microsoft MVP (C#). 
------------------------------------------------------------------------



-- 
You received this message because you are subscribed to the Google Groups
"nhusers" group.
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.



-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
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