Solved

LinqToSQL Joins

Posted on 2014-03-10
6
123 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 39918682
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
ID: 39919894
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 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 39920347
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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
LVL 1

Author Comment

by:Dodsworth
ID: 39920534
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 63

Expert Comment

by:Fernando Soto
ID: 39920544
As long as a.TaskId is a column in Appointment and t.TaskId is a column in Task then yes.
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 39925418
Has that answered your question?
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

731 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