Get Property Name by lambda within generic class : <p>This is my generic Container class:</p>

<pre><code>public class Container&lt;T&gt; : IContainer&lt;T&gt; where T : BaseModel, new()
{
    private string include;

    public Container()
    {
    }

    public Container&lt;T&gt; Include(Expression&lt;Func&lt;T&gt;&gt; property)
    {            
        include = GetMemberName(property);
        return this;
    }
}
</code></pre>

<p>Now I want to set the include value like this:</p>

<pre><code>var container = new Container&lt;TestClass&gt;();
// doesn't work
container.Include(x =&gt; x.SomeProperty);
// also doesn't work
container.Include(() =&gt; TestClass.SomeProperty);
</code></pre>

<p>And as result the <code>include</code> should habe the value <code>SomeValue</code>. I also tried a parameterless Function, in the latter case VS says it's missing an object reference for the non-static property.</p>

<p>I got the GetMemberName from this thread: [<a href="https://stackoverflow.com/questions/671968/retrieving-property-name-from-lambda-expression][1]">Retrieving Property name from lambda expression</a></p>
