Linq any - How to select

.net, c#, entity-framework, linq

Solution

you could use join clause:

context.Favorite
  .Where(f => f.UserId == UserId)
  .Join(context.Objects, t => t.ObjectId, u => u.Id, (t, u) => t);

Problem

I have some simple classes that looks like this: ``` Class Favorites Guid UserId Guid ObjectId Class Objects Guid Id String Name ``` With Entity Framework I want to select all the Objects which has been marked as a favorite by a user. So I tried something like this ``` context.Objects.Where( x => x.Id == context.Favorite.Where(f => f.UserId == UserId) .Select(f => f.ObjectId).Any() ); ``` But I don't get it. I also tried with intersect, but what I understand it most be the same type. One User can have many Favorite objects

Original source