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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:00:49+00:00 2026-05-26T07:00:49+00:00

This may sound stupid but I cannot get the MethodInfo of Queryable.Join(…) . I

  • 0

This may sound stupid but I cannot get the MethodInfo of Queryable.Join(...). I want to get it because of How to use a Type variable in a generic method call (C#)

It has 2 available method signatures and I want to get the one without IEqualityComparer, so I need to specify Type[] in GetMethod.

I wrote something like

MethodInfo joinMethod = typeof( Queryable ).GetMethod( "Join", new Type[] { typeof(IEnumerable<>), typeof(Expression<Func<>>), typeof(Expression<Func<>>), typeof(Expression<Func<>>)});

but it doesn’t work. I’m unable to specify the types in generics above, because they are passed as Type from outside (and this is why I need this reflection).

Can anyone tell me how? Thanks!

  • 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-26T07:00:49+00:00Added an answer on May 26, 2026 at 7:00 am

    Working with generics and reflection can be a bit tedious. Your best bet (to keep things simple) is to use GetMethods and filter by what you are looking for.

    //Overly simplified
    MethodInfo joinMethod = typeof(Queryable)
                .GetMethods(BindingFlags.Static | BindingFlags.Public)
                .Where(m => m.Name == "Join" && m.GetParameters().Length == 5)
                .First();
    

    Given that, the MethodInfo is not invokable at this point. You need to make a generic version of it by using joinMethod.MakeGenericMethod(/*type array*/). In your case, you would need to use 4 types: TOuter, TInner, TKey, TResult.

    var genericJoinMethod = joinMethod.MakeGenericMethod(new Type[]{your types here});
    

    Now you can use genericJoinMethod as you’d expect to.

    As far as I know, that is the only way to do it if you don’t know the types at compile-time.

    EDIT:

    Given your comment, I think it should look something like this:

    MethodInfo joinMethod = typeof(Queryable)
                .GetMethods(BindingFlags.Static | BindingFlags.Public)
                .Where(m => m.Name == "Join" && m.GetParameters().Length == 5)
                .First();
    var genericJoinMethod = joinMethod.MakeGenericMethod(typeof(TType), typeof(TType), JoinKeyType, typeof(TType));
    result = genericJoinMethod.Invoke( result, new object[] { result, items, OuterKeySelector, InnerKeySelector, ResultSelector } );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may sound stupid but... When I create big SQL commands I want to
This may sound like a stupid question, but how can I start to use
This may sound stupid, but I'm not quite sure how to get the W
I know this may sound stupid, but i really want to know :) im
This may sound like a completely stupid question, but how can I get the
This may sound like a stupid question but I'm a beginner not just to
This may sound like a stupid question, perhaps it is. But I'm only trying
This may sound like a stupid question, but can DI be used everywhere where
this may sound simple, but somehow I am not able to get out of
This may sound really stupid. but I've got a strange problem with the D

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.