There are two problems in your code:
- Your parameters are backwards. The first parameter has to be the collection, the second the item you're searching for.
- Your type argument is
IEnumerable<int>
, when it should be justint
.
So, the fixed code is:
var callExpression = Expression.Call(
typeof(Enumerable), "Contains", new[] { typeof(int) }, me, ce);
But it seems all the parts of your expression are not actually dynamic, so maybe something like that following would work too:
Expression<Func<Segment, bool>> expression =
s => s.RouteIds.Contains(int.Parse(this.ddlRouteNames.SelectedValue));