Solved

LinqToSQL Joins

Posted on 2014-03-10
6
106 Views
Last Modified: 2016-02-10
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
Comment
Question by:Dodsworth
  • 4
  • 2
6 Comments
 
LVL 62

Expert Comment

by:Fernando Soto
Comment Utility
I am not sure of the question you are asking can you be a little bit more descriptive.
0
 
LVL 1

Author Comment

by:Dodsworth
Comment Utility
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
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 500 total points
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Author Comment

by:Dodsworth
Comment Utility
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
 
LVL 62

Expert Comment

by:Fernando Soto
Comment Utility
As long as a.TaskId is a column in Appointment and t.TaskId is a column in Task then yes.
0
 
LVL 62

Expert Comment

by:Fernando Soto
Comment Utility
Has that answered your question?
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now