1

I am using this function to get nested properties recursively:

public PropertyInfo GetProp(Type baseType, string propertyName)
{
    string[] parts = propertyName.Split('.');

    return (parts.Length > 1) ? GetProp(baseType.GetProperty(parts[0]).PropertyType, parts.Skip(1).Aggregate((a,i) => a + "." + i)) : baseType.GetProperty(propertyName);
}

How could I get values recursively? Thank you.

  • I'm sorry im too busy to come up with a full solution right now but `PropertyInfo` class has a `GetValue` method which I believe I had to use when doing this.. – Sayse Apr 09 '14 at 15:59
  • 3
    Maybe this solution will help you - http://stackoverflow.com/questions/20374144/using-reflection-in-c-sharp-to-generate-entire-property-call-from-string/20374746#20374746 – Konrad Kokosa Apr 09 '14 at 16:00
  • @Konrad Kokosa link was very helpful - http://stackoverflow.com/questions/20374144/using-reflection-in-c-sharp-to-generate-entire-property-call-from-string/20374746#20374746 –  May 12 '14 at 01:44

0 Answers0