I am using linq to sql to pull data from my IQueryable object in my mvc project. In this case, I am trying to find albums that users have in common. Thanks for any help.
Albums.Where(x=>x.userid == _userid && x.userid == _otheruserid);
//This will pull all the respected albums from each user.
//I just would like to pull the albums they have in common
You can use Intersect. Pretty easy:
Edit:
For the code you’ve provided, you want to use a specific field to match on, since you cannot have one Album with two different Users assigned to it. if you want to find albums that are common based on the name, you can try to use this:
but as @EvilPenguin mentioned, you’re probably better off creating a better structure for your tables.