title: How to call property from property in c# expression?
body: <p>I have 3 classes.</p>
  
  <pre><code>    AutoYearMake{
         int Year { get; set; }
         string Make { get; set; }
              }
  
      AutoModel{
         IAutoYearMake AutoYearMakeParent { get; set; }
         string Model { get; set; }
              } 
  
      AutoTrim{
          IAutoModel AutoModelParent { get; set; }
          string Trim { get; set; }
              }
  </code></pre>
  
  <p>I need to create a query to a database. How can I get dynamically an expression like:</p>
  
  <pre><code>   Expression&lt;Func&lt;AutoTrim, bool&gt;&gt; expression =  expression = t =&gt; t.AutoModelParent.AutoYearMakeParent.Year == year.Value
                                &amp;&amp; t.AutoModelParent.AutoYearMakeParent.Make 
                                == make &amp;&amp; t.AutoModelParent.Model == model; 
  </code></pre>
  
  <p>This is my code. It doesn't work.</p>
  
  <pre><code>        ParameterExpression parameter = Expression.Parameter(typeof (AutoTrim), "a");
  
          MemberExpression yearProp = Expression.Property(parameter, "AutoModelParent.AutoYearMakeParent.Year");
          MemberExpression makeProp= Expression.Property(parameter, "AutoModelParent.AutoYearMakeParent.Make");
          MemberExpression modelProp= Expression.Property(parameter, "AutoModelParent.Model");
  
          Expression right = Expression.Constant(2014);
          Expression e1 = Expression.Equal(yearProp, right);
          right = Expression.Constant("make");
          Expression e2 = Expression.Equal(makeProp, right);
          right = Expression.Constant("model");
          Expression e3 = Expression.Equal(modelProp, right);
  
          Expression predicateBody = Expression.AndAlso(e1, e2);
          Expression final = Expression.AndAlso(e1, e2); 
  </code></pre>
  
  <p>How can I resolve this problem? I tried to use Expression.Call. It wasn't right way.</p>