Getter function with switch case?
<pre><code>public User getByField(string field, string stringToFilter)
{
    string fieldToReturn;
    switch (field)
    {
        case "id":
            fieldToReturn = "u.pk_user_id";
            break;
        case "username":
            fieldToReturn = "u.user_username";
            break;
    }

    var result = (from u in dc.Users
                  where fieldToReturn == stringToFilter
                  select fieldToReturn).Single();
    return result;
}
</code></pre>

<p>I am trying to create one getter for all my fields using a switch case, because otherwise I would have to create a lot of setters (There are more cases than displayed here). But when I try to return the result, it says it is a String, rather than a User. I suppose it is because I am using a String in the LINQ-query, but I've tried solving it but can't figure it out how to do.</p>
