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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:00:53+00:00 2026-05-14T00:00:53+00:00

Yesterday I posted this question regarding using lambdas inside of a Join() method to

  • 0

Yesterday I posted this question regarding using lambdas inside of a Join() method to check if 2 conditions exist across 2 entities. I received an answer on the question, which worked perfectly. I thought after reading the MSDN article on the Enumerable.Join() method, I’d understand exactly what was happening, but I don’t. Could someone help me understand what’s going on in the below code (the Join() method specifically)? Thanks in advance.

if (db.TableA.Where( a => a.UserID == currentUser )
      .Join( db.TableB.Where( b => b.MyField == someValue ),
             o => o.someFieldID,
             i => i.someFieldID,
             (o,i) => o )
      .Any()) 
{
    //...
}

Edit:
Specifically, I’m curious about the last 3 parameters, and what’s actually going on. How do they result in the signature requirements of Func(TOuter, TKey), Func(TInner, TKey) etc.

  • 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-14T00:00:53+00:00Added an answer on May 14, 2026 at 12:00 am

    Eric and Nick have both provided good answers.

    You may also write the Linq query expression using query syntax (vs. method syntax, which you are using in your example):

    var query = from a in db.TableA 
                join b in db.TableB on a.someFieldID equals b.someFieldID
                where a.UserID == currentUser && b.MyField == someValue
                select a;
    
            if (query.Any()) {
                ...
            }
    

    Update:

    You seem to be stuck on the lambda expressions. It’s a function that you pass around like a variable. A lambda expression is equivalent to an anonymous delegate (or anonymous method, to me more general).

    Here is your query with the lambda expressions as delegates (replace EntityType with the type of your entity returned from TableA, of course):

    if (db.TableA.Where( delegate(EntityType a) { return a.UserID == currentUser; } ) 
      .Join( db.TableB.Where( delegate(EntityType b) { return b.MyField == someValue; } ), 
             delegate(EntityType o) { return o.somefieldId); },
             delegate(EntityType i) { return i.someFieldId); },
             delegate(EntityType o, EntityType i) { return o; }) 
      .Any())  
    

    {
    //…
    }

    NOTE: A lambda expression has important aspects that make it more than just an equivalent for anonymous methods. I recommend that you look through other SO questions and read online about lambda expressions in particular. They allow for very powerful ideas to be expressed in a much simpler and elegant way. It’s a deep topic, but the basics are easy enough to understand. It’s a function that you can pass around like a variable, or as a parameter to other functions.

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

Sidebar

Related Questions

This is a followup to a question I posted yesterday. I thought everything was
Yesterday, I posted a question on some tips doing this Remote Client-Server Application in
I posted this question yesterday: yesterday's question One of the response was to use
I posted a question yesterday regarding issues that I was having with my backpropagating
I posted this question yesterday and the answer I go mentioned that I should
Yesterday I posted this question about protecting files: Protecting the app sandbox As mentioned,
I posted this question yesterday evening, which has led me to discover a huge
I all. I posted yesterday a question regarding dates not sent with jquery-ajax and
This is related to a question posted yesterday . class A { public: mutable
this is a rephrasing of a question I posted yesterday. I got an answer

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.