UPDATE:如何转换表达式树?
我会尽力解释我的意思。 有2 不同类(MyClass1的和MyClass2)和方法的Class1转换为等级2:
class MyClass1
{
//...Some fields and properties
}
class MyClass2
{
//...Some fields and properties
}
public MyClass2 Convert(MyClass1 class1)
{
//.....
return class2Object;
}
有2点不同的方法:
void method1(Expression<Func<MyClass1, bool>> where, //other parameters)
{
//some operations
//...............
//need to call method2(Expression<Func<MyClass2, bool>>)
// BUT! How do I convert Expression<Func<MyClass1, bool>>
// to Expression<Func<MyClass2, bool>>
}
void method2(Expression<Func<MyClass2, bool>> where, //other parameters)
{
//some operations
}
如何转换表达< Func键< MyClass1,bool >>至表达式< Func < MyClass2,bool >>
既然'MyClass1'和'MyClass2'不能互相转换,你怎么期望转换委托? – 2011-02-27 12:08:43
直到你定义'MyClass1'和'MyClass2'之间的显式转换,你甚至不能开始。 – 2011-02-27 12:09:16
看看我的编辑。 – Alexandre 2011-02-27 12:14:32