Best way to pass a get/set property as an argument without reflection
<p>Sometimes, when handling data transfer objects (for instance retrieved from the database or a csv file), it's nice to write some helper functions to move the data.</p>

<p>For instance:</p>

<pre><code>class MyDto
{
    public string Name { get; set; }
}

class MyBusinessObject
{
    public string Name { get; set;}
}
</code></pre>

<p>I'd like to write something like:</p>

<pre><code>MyDto source;
MyBusinessObject target;

var hasChanged = target.Set(source, source =&gt; source.Name, target =&gt; target.Name); // lamdba expressions, or whatever it takes to make it work
</code></pre>

<p>with the extension method:</p>

<pre><code>public static bool Set&lt;TS, TT, TValue&gt;(this TS source, IGetProperty&lt;TS, TValue&gt; sourceGetProperty, IGetOrSetProperty&lt;TT, TValue&gt; targetGetOrSetProperty)
{
    var sourceValue = sourceGetProperty.Invoke(source);
    var actualValue = targetGetOrSetProperty.Invoke(target);
    if(sourceValue != actualValue)
    {
        targetGetOrSetPropery.Invoke(target, sourceValue);
        return true;
    }
    return false;
}
</code></pre>

<p>I made up the <code>IGetProperty</code> and <code>IGetOrSetProperty</code>. Is it possible to implement them some way without using reflection (so that it's compile-time checked)?</p>

<p>Or is there an elegant way to handle this kind of situation?</p>

<p><em>EDIT: the example was misleading because the goal wasn't to use an Automapper, but to represent somehow properties as objects. I realize that it's pretty close in fact to the idea of using properties as "ref" for instance, so it's more a language-related question that has always been answered here: <a href="https://stackoverflow.com/questions/1402803/passing-properties-by-reference-in-c-sharp">Passing properties by reference in C#</a></em></p>