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 7922717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:03:47+00:00 2026-06-03T17:03:47+00:00

I am having trouble getting one of my LINQ to SQL queries to work

  • 0

I am having trouble getting one of my LINQ to SQL queries to work correctly. I have three tables setup as follows:

Vendors
id – primary key

Manufacturers
id – primary key

ManufacturerVendorRelationships
id – primary key
manufacturer_id – foreign key to manufacturer.id
vendor_id – foreign key to vendor.id

I am trying to write a LINQ to SQL query that will fetch the Vendors that are not currently related to a given manufacturer. For example, the following table data should only result in 2 vendors for the manufacturer with ID of 1. Can someone please help me with the LINQ to SQL for this example? Right now, the application is doing this logic. Thanks in advance.

Vendors
ID
1
2
3
4
5

Manufacturers
ID
1
2
3
4
5

ManufacturerVendorRelationships
ID               ManufacturerID                   VendorID
1                1                                1
2                1                                2
3                1                                3
  • 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-03T17:03:50+00:00Added an answer on June 3, 2026 at 5:03 pm

    Maybe something like this:

    var result=(
            from v in db.Vendors
            where !db.ManufacturerVendorRelationships
                     .Select(s=>s.VendorID)
                     .Contains(v.ID)
            select v
        );
    

    Or if you want it like a field:

    var result=(
            from v in db.Vendors
            select  new
            {
                v.ID,
                HasManufacturer=db.ManufacturerVendorRelationships
                               .Select(s=>s.VendorID)
                               .Contains(v.ID)
            }
        );
    

    where db is the linq data context

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

Sidebar

Related Questions

I am having trouble getting my filters/validators to work correctly on my form, so
I'm having a bit of trouble getting a SQL query to work. Some background
I am learning python and am having trouble getting this program to work correctly.
Having trouble getting one portion of my code to work. Building a rudimentary linked
i am having trouble getting this to work, can any one spot the issue?
I am having trouble getting things moved in a database. I have two tables
I have created a soundboard and am having trouble getting just one sound to
I am having trouble getting this accomplished. I have one formset with 5 extra
I'm having trouble getting the following to work in SQL Server 2k, but it
I am having trouble getting HashMaps and ArrayLists to work correctly on my computer.

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.