I have a series of objects that all have a similar property that is a List of the Ids of the groups to which they belong (many parents per child).
I'm having trouble programatically implementing the Linq Expression necessary to make this filter work correctly.
This is what I have so far:
IQueryable result = null;
if (!string.IsNullOrWhiteSpace(this.ddlRouteNames.SelectedValue))
{
ConstantExpression ce = Expression.Constant(int.Parse(this.ddlRouteNames.SelectedValue));
ParameterExpression pe = Expression.Parameter(source.ElementType);
MemberExpression me = Expression.Property(pe, this.Column.Name);
MethodCallExpression mce = Expression.Call(typeof(List<int>), "Contains", new[] { typeof(int) }, me, ce);
result = source.Provider.CreateQuery(mce);
}
return result;
I'm getting an exception when trying to create my MethodCallExpression:
No method 'Contains' exists on type 'System.Collections.Generic.List`1[System.Int32]'.
Any pointers on where to begin?