Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I make a little modification of your lambda query. </p> <p>When the parameter type si generic you must make that like that :</p> <p>I add <code>pi.ParameterType.GetGenericTypeDefinition()</code></p> <p>and </p> <pre><code>(m.ReturnType.IsGenericType ? m.ReturnType.GetGenericTypeDefinition() : m.ReturnType) == returnType) </code></pre> <p>In this way the method working very fine</p> <pre><code>MethodInfo foo1 = (from m in t.GetMethods(BindingFlags.Public | BindingFlags.Static) where m.Name == name &amp;&amp; m.GetGenericArguments().Length == genericArgTypes.Length &amp;&amp; m.GetParameters().Select(pi =&gt; pi.ParameterType.IsGenericType ? pi.ParameterType.GetGenericTypeDefinition() : pi.ParameterType).SequenceEqual(argTypes) &amp;&amp; (returnType==null || (m.ReturnType.IsGenericType ? m.ReturnType.GetGenericTypeDefinition() : m.ReturnType) == returnType) select m).FirstOrDefault(); if (foo1 != null) { return foo1.MakeGenericMethod(genericArgTypes); } return null; </code></pre> <p>Example :</p> <p>With the modification of the method i can call this extension method</p> <pre><code>public static IQueryable&lt;T&gt; FilterCulture&lt;T&gt;(this Table&lt;T&gt; t, IDatabaseFilter filter) </code></pre> <p>With my new Helper like this</p> <pre><code>var QueryableExpression = MethodInfoHelper.GetGenericMethod(typeof(LinqFilterExtension), "FilterCulture", new Type[] { rowType }, new Type[] { typeof(Table&lt;&gt;), typeof(IDatabaseFilter) }, typeof(IQueryable&lt;&gt;)); </code></pre> <p>The signature of my helper is </p> <pre><code> public static MethodInfo GetGenericMethod(Type t, string name, Type[] genericArgTypes, Type[] argTypes, Type returnType) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload