When invoke the expression, i become an InvalidOperationException
variable ‘___zip_0’ of type ‘System.Int32’ referenced from scope ”, but it is not defined
public class AddressByZipSpecification : Specification<Address>
{
public int _zip { get; set; }
public AddressByZipSpecification(int zip)
{
_zip = zip;
}
public override Expression<Func<Address, bool>> ToExpression()
{
return address => address.Zip == _zip;
}
}
var zipSpec = new AddressByZipSpecification(12);
var address = await dbContext.Address.Where(a => zipSpec.ToExpression().Invoke(a)).ToListAsync();
I am at a loss, what happend in the expression tree