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
Maybe something like this:
Or if you want it like a field:
where db is the linq data context