troubleshooting Question

LINQ Query Help - How to do an OUTER JOIN

Avatar of sharizod
sharizodFlag for Canada asked on
DatabasesMicrosoft SQL Server 2008
2 Comments1 Solution319 ViewsLast Modified:
Hi experts,
I am in urgent need of assistance on modifying a LINQ query to get around an issue with some
software I am trying to release.  I need to be able to have a join between two tables and,
if the joining key is null (eg: record doesnt exist for a given id in table 2 but does in table 1),
then I need to show all values with the null values in table 2 alongside the values that do exist
in table 1.  I am new to LINQ and am trying to wrap my head around it.  It does seem fairly
straightforward though until I wanted to modify the requirements of the join.  Below is my
expression that I need modified to an OUTER join.  The OUTER join needs to be able to
show all records in the join even when the key for the join is null in one of the tables.

Thanks in advance for any assistance!
Bob

Public Sub New(ByVal dataSourceFilePath As String)
        MyBase.New()
        Dim connectionString As String = String.Format(CultureInfo.InvariantCulture, "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=""{0}"";Persist Security Info=True", dataSourceFilePath)
        oleDbConnection = New OleDbConnection(connectionString)
         dataContext = New TrackingAccessDataContext(oleDbConnection) '** Our dbml schema file ref
    End Sub

        Dim vehicleLocations = (From v In dataContext.Vehicles _
            Join l In dataContext.Locations On v.VehicleID Equals l.VehicleID _
            Where v.VehicleID = vehicleId AndAlso v.[GUID] = Me.GUID.ToString _
            Order By l.[Date] Descending _
            Select New With {.Vehicle = v, .Location = l})
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros