Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8898357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:35:40+00:00 2026-06-15T00:35:40+00:00

I am using linq to sql to pull data from my IQueryable object in

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T00:35:42+00:00Added an answer on June 15, 2026 at 12:35 am

    You can use Intersect. Pretty easy:

    Albums.Where(x=>x.userid ==_userid) 
    .Intersect(Albums.Where(x=>x.userid== _otheruserid));
    

    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:

     Albums.Where(x=>x.userid ==_userid).Select(x=>x.Name) 
        .Intersect(Albums.Where(x=>x.userid== _otheruserid).Select(x=>x.Name)); 
    

    but as @EvilPenguin mentioned, you’re probably better off creating a better structure for your tables.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm simply trying to get data from two sql server db tables using ado.net
I'm using Linq to SQL to query an Object from DB. I pass it
I'm using LINQ to SQL to pull records from a database, sort them by
How to select all columns from tables in join using linq Sql: select CTRL_RUN_JOB.*,
using Linq-to-SQL I'd like to prefetch some data. 1) the common solution is to
I have started using Linq to SQL for a project im working on and
I'm using Linq to SQL within an ASP.NET MVC application. The model consists of
I am using Linq to SQl to query the data. When I write a
I am using LINQ-to-SQL class. It has a method object.InsertOnSubmit() .But it returns void
I am using linq to sql. I want to update my changed in object

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.