开发者

How to modify an expression to pass it to a method

开发者 https://www.devze.com 2023-03-20 14:47 出处:网络
The problem is: public GetAll(Expression<Func<C开发者_StackOverflow中文版ampModel, bool>> whereCondition)

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 whereConditionso 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?

0

精彩评论

暂无评论...
验证码 换一张
取 消