【发布时间】:2011-07-15 03:31:52
【问题描述】:
问题是:
public GetAll(Expression<Func<CampModel, bool>> whereCondition)
{
// and it should call another GetAllCampsFromRepo method that gets Camps from a repository
}
public IList<Camp> GetAllCampsFromRepo(Expression<Func<Camp, bool>> whereCondition)
{
return // Blah blah the list of Camps
}
所以问题是如何正确地从第一个方法的主体调用第二个方法,映射不同类型的属性 - CampModel 对象到 Camp 对象(它们相似但不同)
如何转换whereCondition以便将其传递给GetAllCampsFromRepo?因为我不能按原样通过:
GetAllCampsFromRepo(whereCondition)
我可以使用 System.Linq.Expressions.ExpressionVisitor 之类的东西并修改原始表达式吗?该怎么做?
【问题讨论】:
标签: c#-4.0 expression