How do I define a property to read an attribute from, without instantionating an object?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/5654853/how-do-i-define-a-property-to-read-an-attribute-from-without-instantionating-an">How do I define a property to read an attribute from, without instantionating an object?</a>  </p>
</blockquote>



<p>Suppose I have:</p>

<pre><code>class Person
{
    [ColumnAttribute("ID")]
    public int Id;
    [ColumnAttribute("Name")]
    public string Name;
    [ColumnAttribute("DateOfBirth")]
    public date BirthDate;
}
</code></pre>

<p>I have a DAL which which have a method that will return a List of Person objects.<br>
Suppose that method is defined as:   </p>

<pre><code>Person.GetAllByAge(int Age, ??? SortBy)  
</code></pre>

<p>This method will return a list of Persons that have a given age and they will be sorted by the <code>SortBy</code> parameter which i defined as <code>???</code> because I don't know what kind of type it should be.  </p>

<p>One possible example is that this function is defined as:</p>

<pre><code>Dal.Person.GetAllByAge(int Age, string SortBy) 
</code></pre>

<p>so an example usage would be:</p>

<pre><code>Dal.Person.GetAllByAge(25, "DateOfBirth")
</code></pre>

<p>But this definition is not strongly typed and if I change the Column name in the Database then this will fail at runtime.  </p>

<p>How can I change this to take a property on which to sort instead of it being a string?  </p>

<p>For example a usage like this would be very nice:</p>

<pre><code>Dal.Person.GetAllByAge(25, BirthDate)
</code></pre>

<p>or</p>

<pre><code>Dal.Person.GetAllByAge(25, p=&gt;p.BirthDate)
</code></pre>

<p>where <code>BirthDate</code> is the name of the property to sort on.  </p>
