I have a LINQ expression which calls another expression which also calls another expression…
public static Expression<Func<Models.Order, Models.Product,decimal?>> _ExpressionOfGetCounterValue
{
get
{
var _getAmountProxy = Product._ExpressionOfGetAmount;
var _convertQuantityProxy = Product._ExpressionOfConvertQuantity;
Expression<Func<Models.Order, Models.Product, decimal?>> cv =
(order,product) => (
_getAmountProxy.Invoke(
order.Product,
_convertQuantityProxy.Invoke(order.Product,order.Quantity),
order.Product.Price));
return cv;
}
}
public static Expression<Func<Models.Product, decimal?, decimal?>> _ExpressionOfConvertQuantity
{
get
{
Expression<Func<Models.Product, decimal?, decimal?>> convertQuantity =
(product, quantity) => ModelEntities.DoubleToDecimal(
ModelEntities.DecimalToDouble(quantity.Value)
* Math.Pow(10.0, ModelEntities.DecimalToDouble(product.QuantityDecimals))
);
return convertQuantity;
}
}
When executing this, I get an error InvalidOperationException: The parameter ‘order’ was not bound in the specified LINQ to Entities query expression.
This exception comes from _convertQuantityProxy .Invoke(order.Product,order.Quantity)
How can I pass the original parameter “order” to this call ?
Please note that I use LinqKit / AsExpandable() function.
Thank you.
Finally I have found, I have to return
return cv.Expand();