Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 332563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:52:42+00:00 2026-05-12T09:52:42+00:00

Hi how do you do joins in linq to sql? I see they have

  • 0

Hi how do you do joins in linq to sql?

I see they have the key word join and group join but what kind of joins are they?

Left, Right, Cross, Inner?

Also how do I select certain columns once I am done?

Like

Select Column1, Column2
From Table A;

Either query or method syntax is fine. I still can’t decide what I like better each seem to have their pluses.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T09:52:42+00:00Added an answer on May 12, 2026 at 9:52 am

    As a first step, I would definitely recommend reading Scott Guthrie’s excellent Using Linq-to-SQL multi-part tutorial. It covers a lot of those Linq-to-SQL basics.

    Also check out the Hooked on LINQ 5 minute overview – as it mentioned there, often in Linq-to-SQL, you really don’t even need to express JOINs yourself – LINQ-to-SQL handles a lot of those for you directly by exposing entity references and entity set references.

    If you then conclude you really MUST use an explicit JOIN, Bilal Haidar shows nicely how to do an explicit LEFT OUTER JOIN in his blog post.

    The “normal” case of an INNER JOIN is relatively simple – you just add a

    from c in customers
      join o in orders on o.customerid equals c.customerid
    

    to your query.

    As for selecting individual fields – see Scott Guthrie’s intro article series – he explains it in great detail!

    Basically, you can do one of three things:

    • select an entire entity (like a customer) and get back all of the information for it
    • select some fields into a new existing type (e.g. “CustomerOrder” type)
    • select some fields into a new anonymous type

    This would select all customer who have an order:

       from c in customers
          join o in orders on o.customerid equals c.customerid
          select c;
    

    This would select all customer and orders into a new “CustomerOrder” type that already exists in your project somewhere:

       from c in customers
          join o in orders on o.customerid equals c.customerid
          select new CustomerOrder { CustomerName = c.Name, 
                                     CustomerID = c.CustomerId,
                                     OrderDate = o.OrderDate, ...... } ;
    

    This would select the customer ID and order date into a new, anonymous type for you to use:

       from c in customers
          join o in orders on o.customerid equals c.customerid
          select new { CustomerID = c.CustomerId, OrderDate = o.OrderDate } ;
    

    It’s a strong type – and there’s a full-fledged .NET CLR type behind this – you just don’t know its name 🙂 But you can use these elements in code, you’ll get Intellisense and all – excellent for a quick temporary manipulation of some data.

    Marc

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.