score:2

Accepted answer

something like (edited after re-reading the question) - but note that expression.invoke doesn't work on ef in 3.5sp1 (but it is fine in linq-to-sql):

using system;
using system.collections.generic;
using system.linq;
using system.linq.expressions;

class dept
{
    public string deptname { get; set; }
}
public static class program
{
    static void main()
    {
        ilist<char> chars = new list<char>{'a','b'};
        dept[] depts = new[] { new dept { deptname = "alpha" }, new dept { deptname = "beta" }, new dept { deptname = "omega" } };
        var count = testing(depts.asqueryable(), dept => dept.deptname, chars).count();
    }

    public static iqueryable<t> testing<t>(this iqueryable<t> queryabledata, expression<func<t,string>> pi, ienumerable<char> chars)
    {
        var arg = expression.parameter(typeof(t), "x");
        var prop = expression.invoke(pi, arg);
        expression body = null;
        foreach(char c in chars) {
            expression thisfilter = expression.call(prop, "startswith", null, expression.constant(c.tostring()));
            body = body == null ? thisfilter : expression.orelse(body, thisfilter);
        }
        var lambda = expression.lambda<func<t, bool>>(body ?? expression.constant(false), arg);
        return queryabledata.where(lambda);
    }
}

Related Query

More Query from same tag