public class OrderModelSapNumber : WhereSpecification<OrderModel>
{
private readonly string Sap;
public OrderModelSapNumber(string sap)
{
Sap = sap;
}
public override Expression<Func<OrderModel, bool>> ToExpression()
{
if (Sap == null || Sap == "") return o => true;
return o => o.OrderItems.Any(oi => oi.Component.SAP != null && oi.Component.SAP.Contains(Sap, StringComparison.InvariantCultureIgnoreCase));
}
}
But when it's run there is an issue "Property 'API.Model.Order.ComponentModel Component' is not defined for type 'API.Model.Order.OrderModel' (Parameter 'property')". I think there is a problem with lambda. Am I right the lambda doesn't see Component property?
Edit: the error is in line exprBody = (BinaryExpression)new ParameterReplacer(paramExpr).Visit(exprBody); in ToExpression() method.
In my specification I have some expression:
But when it's run there is an issue
"Property 'API.Model.Order.ComponentModel Component' is not defined for type 'API.Model.Order.OrderModel' (Parameter 'property')"
. I think there is a problem with lambda. Am I right the lambda doesn't see Component property?Edit: the error is in line
exprBody = (BinaryExpression)new ParameterReplacer(paramExpr).Visit(exprBody);
inToExpression()
method.