dimanche 28 juin 2015

Applying dynamically built expression on collection throws exception

I have the following class:

public class Order
{
    public string Code { get; set; } 
}

And I have built dynamically an Expression, which looks like this:

enter image description here

and I'm building an extension method which looks like:

enter image description here

I have a list of orders which, List<Order> of the expression type and when I apply the filter like this:

var buildExpressionFilter = dynamically constructed Expression here
var orders = GetOrders();
var result = orders.Where(buildExpressionFilter).ToList();

I get the following error: enter image description here

Is obviously that buildExpressionFilter is not properly constructed but I cannot figure out what is the issue.

Does anyone have an idea on how to fix this issue? What may be wrong with my buildExpressionFilter?

Aucun commentaire:

Enregistrer un commentaire