Hi,

 

I'm a little puzzled on the best way to achieve what I want to do, I'm not
quite sure if this post is NHibernate specific / more of an architectural
question but I'm hoping someone can help anyway.

 

Basically I want to return a list of music mixes as a paged result, but also
eager load all the required data along with it. I have managed to eager load
the collections I need such as track lists etc fine.

 

But I also need to display in my MVC view along with the mix weather the
user has added this mix to their favourites list and weather they have hit
the like button for each mix.

 

I can't do a subselect for the data because my POCO class obviously doesn't
contain a property to hold this data because it's not relevant for each mix.

 

At the moment when listing each mix I am performing the following to
determine if a user has added this mix to their favourites:

 

// input is the current mix and user is the logged in user

viewModel.IsFavouriteByUser =

                    user.AudioFavourites.Where(x => x.Audio ==
input).FirstOrDefault() != null; 

 

But this is returning ALL the users favourites just to determine if it's a
favourite for this mix which isn't what I want because a user could have
hundreds / thousands of favourites.

 

Can anyone shed some light on the best way to tackle this situation?

 

Thank You!

Paul

-- 
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