How to use a Type variable in a generic method call (C#)

前端 未结 2 334
南旧
南旧 2021-01-25 08:08

I have a Type variable t passed into a method, and I want to use it as a generic parameter when calling IQueryable.Join like the following



        
2条回答
  •  一生所求
    2021-01-25 08:37

    Basically you've got to call the method with reflection:

    • Get the generic method template with Type.GetMethod
    • Call MakeGenericMethod passing in your 4 type parameters
    • Invoke the method passing in the regular arguments

    It's a pain :(

提交回复
热议问题