[SOLVED] How to translate SQL to LINQ with individual field joins?

Issue

I have a SQL statement, that I want to implement in a .NET website project. I don’t understand how to join in a particular field, as the fields aren’t available when I just select from the table.

My SQL

SELECT *

FROM [vResidence] c

JOIN [vJobs] j on c.UID = j.UID

This is the LINQ I have tried, but I am stuck at the ‘ON’ part:

results = (from j in vJobs

join cr in vResidence on ??? )

When I try ‘j.’, the only option I get is ‘equals’.

Solution

You can follow as this.connect to tables as JOIN use equals keyword

var result = from r in vResidence
             join j vJobs on r.UID equals  j.UID
             select new {[yourcolnum]};

Answered By – D-Shih

Answer Checked By – Katrina (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *