How to convert GetFuncType using LINQBridge

154 Views Asked by At

I have a client using .net and I am using LINQBride with some existing code that uses LINQ. I don't really know much about linq but am wondering if there is a quick conversion using LINQBridge for this expression

DynamicMethod.CreateDelegate(Expression.GetFuncType(typeof(IDataReader), type));

Thanks

1

There are 1 best solutions below

0
On BEST ANSWER

LinqBridge only implements Linq to Objects, it doesn't support expressions. But you can achieve something similar using reflection:

static Type GetFuncType(params Type[] typeArgs)
{
    string typeName = "System.Func`" + typeArgs.Length;
    Type genericTypeDef = typeof(Func<>).Assembly.GetType(typeName); // Func<,...,>
    return genericTypeDef.MakeGenericType(typeArgs); // Func<TArg1, ..., TResult>
}