ParameterExpression c = Expression.Parameter(typeof(Pic), "c");
Expression condition = Expression.Constant(false);
Expression<Func<Pic, bool>> end;
if (search != "" && search != null)
{
string[] b = search.Split('^');
foreach (string s in b)
{
if (s != null && s != "")
{
string[] e = s.Split('&');
if (e[1] != null && e[1] != "")
{
Expression con = Expression.Call(
Expression.Property(c, typeof(Pic).GetProperty(e[0].ToString())),
typeof(string).GetMethod("Equals", new Type[] { typeof(string) }),
Expression.Constant(e[1].ToString()));
condition = Expression.Or(con, condition);
}
}
}
end =
Expression.Lambda<Func<Pic, bool>>(condition, new ParameterExpression[] { c });
}
else
{
end = s => 1 == 1;
}