我有一个使用.net的客户端,我正在使用LINQBride和一些使用LINQ的现有代码。我真的不太了解linq,但我想知道是否可以使用LINQBridge对此表达式进行快速转换
DynamicMethod.CreateDelegate(Expression.GetFuncType(typeof(IDataReader), type));谢谢
发布于 2012-06-02 06:47:17
LinqBridge只实现了Linq to Objects,不支持表达式。但是您可以使用反射来实现类似的功能:
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>
}https://stackoverflow.com/questions/10857935
复制相似问题