2

The problem is:

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
}

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?

iLemming
  • 34,477
  • 60
  • 195
  • 309

1 Answers1

3

Here is a related question that might help. How do I translate an expression tree of one type to a different expression type?

Community
  • 1
  • 1
agent-j
  • 27,335
  • 5
  • 52
  • 79