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 99167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:20:09+00:00 2026-05-11T00:20:09+00:00

I need to do a LINQ2DataSet query that does a join on more than

  • 0

I need to do a LINQ2DataSet query that does a join on more than one field (as

var result = from x in entity join y in entity2         on x.field1 = y.field1  and            x.field2 = y.field2 

I have yet found a suitable solution (I can add the extra constraints to a where clause, but this is far from a suitable solution, or use this solution, but that assumes an equijoin).

Is it possible in LINQ to join on multiple fields in a single join?

EDIT

var result = from x in entity              join y in entity2              on new { x.field1, x.field2 } equals new { y.field1, y.field2 } 

is the solution I referenced as assuming an equijoin above.

Further EDIT

To answer criticism that my original example was an equijoin, I do acknowledge that, My current requirement is for an equijoin and I have already employed the solution I referenced above.

I am, however, trying to understand what possibilities and best practices I have / should employ with LINQ. I am going to need to do a Date range query join with a table ID soon, and was just pre-empting that issue, It looks like I shall have to add the date range in the where clause.

Thanks, as always, for all suggestions and comments given

  • 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. 2026-05-11T00:20:10+00:00Added an answer on May 11, 2026 at 12:20 am

    The solution with the anonymous type should work fine. LINQ can only represent equijoins (with join clauses, anyway), and indeed that’s what you’ve said you want to express anyway based on your original query.

    If you don’t like the version with the anonymous type for some specific reason, you should explain that reason.

    If you want to do something other than what you originally asked for, please give an example of what you really want to do.

    EDIT: Responding to the edit in the question: yes, to do a ‘date range’ join, you need to use a where clause instead. They’re semantically equivalent really, so it’s just a matter of the optimisations available. Equijoins provide simple optimisation (in LINQ to Objects, which includes LINQ to DataSets) by creating a lookup based on the inner sequence – think of it as a hashtable from key to a sequence of entries matching that key.

    Doing that with date ranges is somewhat harder. However, depending on exactly what you mean by a ‘date range join’ you may be able to do something similar – if you’re planning on creating ‘bands’ of dates (e.g. one per year) such that two entries which occur in the same year (but not on the same date) should match, then you can do it just by using that band as the key. If it’s more complicated, e.g. one side of the join provides a range, and the other side of the join provides a single date, matching if it falls within that range, that would be better handled with a where clause (after a second from clause) IMO. You could do some particularly funky magic by ordering one side or the other to find matches more efficiently, but that would be a lot of work – I’d only do that kind of thing after checking whether performance is an issue.

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

Sidebar

Ask A Question

Stats

  • Questions 116k
  • Answers 116k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Actually the touch method is already in Rails 2.3.x, so… May 11, 2026 at 10:32 pm
  • Editorial Team
    Editorial Team added an answer First check into using a global reset style sheet (see… May 11, 2026 at 10:32 pm
  • Editorial Team
    Editorial Team added an answer Using bash, this will do the trick: $ sort -t$'\t'… May 11, 2026 at 10:32 pm

Related Questions

I need to do a dump of a table on a remote server, but
I need to do a simple mail merge in OpenOffice using C++, VBScript, VB.Net
I need to do a lot of searches of certain patterns in source files
I need to do a join across two different database servers (IPs 10.0.0.50 and

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.