SpecificationPattern icon indicating copy to clipboard operation
SpecificationPattern copied to clipboard

Property <some prop from class X> is not defined for type <some prop from class Y> (Parameter 'property')

Open macik1423 opened this issue 1 year ago • 0 comments

In my specification I have some expression:

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.

macik1423 avatar Feb 13 '24 06:02 macik1423