title: Why are some object properties UnaryExpression and others MemberExpression?
body: <p>Acting on the answer to my <a href="https://stackoverflow.com/questions/3558974/select-a-model-property-using-a-lambda-and-not-a-string-property-name">Select a model property using a lambda and not a string property name</a> question, wanting to add properties to a collection as follows: </p>
  
  <pre><code>var props = new ExportPropertyInfoCollection&lt;JobCard&gt;();
  props.Include(model =&gt; model.BusinessInstallNumber).Title("Install No").Width(64).KeepZeroPadding(true);
  props.Include(model =&gt; model.DeviceName).Title("Device").Width(70);
  props.Include(model =&gt; model.DateRequested).Title("Request Date").Format("{0:dd/MM/yyyy}").Width(83);
  </code></pre>
  
  <p>I wrote the following code in the <code>Include</code> method:</p>
  
  <pre><code>public class PropertyCollection&lt;T&gt;
  {
      public void Include(Expression&lt;Func&lt;T, object&gt;&gt; expression)
      {
          var memberExpression = expression.Body as MemberExpression;
          if (memberExpression != null)
          {
              var pes = new ExportPropertyInfoBuilder {Property = new ExportPropertyInfo {Property = memberExpression.Member as PropertyInfo}};
              Properties.Add(pes.Property.Property.Name, pes.Property);
              return pes;
      }
  </code></pre>
  
  <p>However, on running the code, I found some of the lambdas yielded <strong>MemberExpression</strong> values as expected, but others yielded <strong>UnaryExpression</strong> values.  I had to change the first line of code to the following before I could add all my properties using lambdas:</p>
  
  <pre><code>var memberExpression = expression.Body as MemberExpression ?? ((UnaryExpression) expression.Body).Operand as MemberExpression;
  </code></pre>
  
  <p>All the properties are 'simple' types, i.e. string, DateTime, int, bool, etc. in a POCO business object.  They are decorated with several varying <strong>DataAnnotations</strong> attributes.</p>
  
  <p>What causes some of the lambdas in my example to yield <strong>MemberExpression</strong> values and others <strong>UnaryExpression</strong> values?  In my example, the first <strong>UnaryExpression</strong> is on the third line, the <strong>DateTime</strong> property, but boolean properties also result in <strong>UnaryExpressions</strong>.</p>