Skip to content

Instantly share code, notes, and snippets.

@apiguy
Created May 25, 2010 03:32
Show Gist options
  • Save apiguy/412721 to your computer and use it in GitHub Desktop.
Save apiguy/412721 to your computer and use it in GitHub Desktop.
public static Func<T, bool> ExBuildEqFuncFor<T>(string prop, object val)
{
var o = Expression.Parameter(typeof(T), "t");
Expression<Func<T, bool>> expression =
Expression.Lambda<Func<T, bool>>(
Expression.Equal(
Expression.PropertyOrField(o, prop),
Expression.Constant(val)), o);
return expression.Compile();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment