I have two Classes :
class Customer
{
public string Fullname { get; set; }
public string Lastname { get; set; }
public int Age { get; set; }
}
and
class CustomerDTO
{
public string Fullname { get; set; }
public string Lastname { get; set; }
public int Age { get; set; }
}
now i h开发者_如何转开发ave an expressiontree Expression<Func<Customer, bool>> expression
Passed between layers , can i convert it to Expression<Func<CustomerDTO, bool>> expression
to be able to use it since it would give compile time error!
thanks in advance
nevermind i made it
Expression<Func<Customer, bool>> expression = v => v.Fullname == "Johm";
var par = Expression.Parameter(typeof(CustomerDTO));
Expression<Func<CustomerDTO, bool>> ex = (Expression<Func<CustomerDTO, bool>>)Expression.Lambda(expression.Body, par);
精彩评论