The problem is:
public GetAll(Expression<Func<C开发者_StackOverflow中文版ampModel, 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
}
So the question is how correctly call the second method from the body of the first method, mapping properties of different types - CampModel object to Camp object (they are similar but different)
How can I transform whereCondition
so I could pass it to the GetAllCampsFromRepo
? Because I can't pass it as is:
GetAllCampsFromRepo(whereCondition)
Can I use something like System.Linq.Expressions.ExpressionVisitor and modify the original expression? How to do that?
Here is a related question that might help. How do I translate an expression tree of one type to a different expression type?
精彩评论