Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 143
  • Last Modified:

LinqToSQL Joins

I'm struggeling with Linq using a single join, but what to do when you have a to use LinqToSQL to join a base entity with many lookups ?

Appointment

Id
ContractId
CustomerId
LocationId
TaskId
EngineerId
0
Dodsworth
Asked:
Dodsworth
  • 4
  • 2
1 Solution
 
Fernando SotoRetiredCommented:
I am not sure of the question you are asking can you be a little bit more descriptive.
0
 
DodsworthAuthor Commented:
An Appointment from a user perspective might read...

id                    2132
Contract        West Coast
Customer      Mr Simon D Jenkins              
Location        249a Hatton Street, Newtown, York, YO23 8YE
Task               Install new alarm system
Engineer       Mr John Reed

Yet the Appointment table is structured as in my initial post, where each column with an Id suffix joins with a related table that holds the user readable data. eg. Appointment.CustomerId links to Customer.CustomerId where Customer has .CustomerId, .Saluation, .Forname, .Initial, .Surname etc.
0
 
Fernando SotoRetiredCommented:
Hi Dodsworth;

See if this gives you what you are looking for.

Dim db = New DataContext()

Dim results = From a In db.Appointment _
              Join c In db.Customer On a.CustomerId Equals c.CustomerId _
              Select a, c 

Open in new window

0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
DodsworthAuthor Commented:
Do I just tag the other joins on like..
Dim db = New DataContext()

Dim results = From a In db.Appointment _
              Join c In db.Customer On a.CustomerId Equals c.CustomerId _
              Join t In db.Task On a.TaskId Equals t.TaskId _
Select a, c, t  

Open in new window


?
0
 
Fernando SotoRetiredCommented:
As long as a.TaskId is a column in Appointment and t.TaskId is a column in Task then yes.
0
 
Fernando SotoRetiredCommented:
Has that answered your question?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now