using System.Linq.Expressions;
public Foo() { Bar = new Bar(); }
public Bar Bar { get; set; }
public Bar() { Baz = new Baz(); }
public Baz Baz { get; set; }
public string SomeProperty { get; set; }
public static string GetPathOfProperty<T>(Expression<Func<T>> property)
string resultingString = string.Empty;
var p = property.Body as MemberExpression;
resultingString = p.Member.Name + (resultingString != string.Empty ? "." : "") + resultingString;
p = p.Expression as MemberExpression;
public static void Main(string[] args)
Console.WriteLine(GetPathOfProperty(() => Foo.Bar.Baz.SomeProperty ));