Skip to content

Instantly share code, notes, and snippets.

@JulienSansot
Created October 17, 2012 10:23
Show Gist options
  • Save JulienSansot/3904846 to your computer and use it in GitHub Desktop.
Save JulienSansot/3904846 to your computer and use it in GitHub Desktop.
foreach (string prop in props)
{
if (prop == "Count")
{
var countMethod = (typeof(Enumerable)).GetMethods().First(m => m.Name == "Count").MakeGenericMethod(type);
expr = Expression.Call(countMethod, expr);
break;
}
PropertyInfo pi = type.GetProperty(prop);
expr = Expression.Property(expr, pi);
type = pi.PropertyType;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment