Solved

LinqToSQL Joins

Posted on 2014-03-10
6
109 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
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 62

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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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 62

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 62

Expert Comment

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

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need to pass a connection through class/Method 1 40
Error in page 3 46
Export import database 4 44
VB.Net - Windows UserName index and length error 4 24
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

863 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

23 Experts available now in Live!

Get 1:1 Help Now