Created
October 17, 2012 10:23
-
-
Save JulienSansot/3904846 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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