How to Retrieve Object from Generic Repository or DB Table with String for table name and int for index of record
<p>Sitting on top of a repository pattern, I have classes for each of my objects (i.e. db tables) to allow for type-based data access:</p>

<pre><code>public abstract class ObjectDataAccessBase&lt;T&gt; : IObjectDataAccess&lt;T&gt;
{
    public virtual IQueryable&lt;T&gt; FindAll()
    {
        ...
    }
    public virtual T Get(int? id)
    {
        ...
    }
    public virtual void Add(T obj)
    {
        ...
    }
    public virtual void Delete(T obj)
    {
        ...
    }
}
</code></pre>

<p>That snippet covers the interface, a common pattern I've seen around.  So from another place in the app, what I have is a string for the name of the object (i.e. db table, or "T"), and an int representing the index of the object I want in the table, which I want to pass to "Get(int? id)" to return the object in question.  But I need to instantiate the correct class first, casted so as to expose the method I need.  I'll need to cast the object, too.</p>

<p>The question is: can that be achieved in this scenario?  If so, how?</p>

<p>(More detail on the context of the call: I have a table which relates one kind of object to possibly many other objects, so I have in this table a column with 'string name' for DB table, and an 'int id' for the index of the object in the table, and I want to be able to retrieve the object from the table, properly casted, with these two bits of information.  Just testing the waters with this pattern, and already I'm wondering whether it's worthwhile...)</p>

<p>Thanks for your help.</p>

<p>Tim.</p>
