Q:

map string to entity for using with generic method

if I have the following classes:
class Fruit {}
class Apple : Fruit {}
class Orange : Fruit {}

and I have method:
public List<Fruit> getFruit<T>() where T : Fruit {

 List<Fruit> fruitList = new List<Fruit>();
 return fruitList.AddRange(session.QueryOver<T>().List());

}

Is it possible to have a dictionary that maps a string to a type that can be passed to this generic method so I can query over the right table?
for example:
Dictionary<string, type> typeMapper = new Dictionary<string, type>()
{
 {"Apple", AppleType??}
};

var myType = typeMapper["Apple"];
List<Fruit> fruitList = getFruit<myType>();

A:

You can use reflection to call a generic method with a Type
[Fact]
public void Test_WithTypesAndReflection_Succeeds()
{
    var typeMapper = new Dictionary<string, Type>()
    {
        { "Apple", typeof(Apple) },
        { "Orange", typeof(Orange) }
    };

    var method = (
        from m in this.GetType().GetMethods(BindingFlags.Instance | BindingFlags.NonPublic)
        where m.Name == "GetFruit"
        where m.GetParameters().Count() == 0
        select m).Single();

    var result = (IEnumerable<Fruit>)method
        .MakeGenericMethod(typeMapper["Apple"])
        .Invoke(this, null);
}

private IEnumerable<Fruit> GetFruit<T>() where T : Fruit
{
    return Enumerable.Empty<T>().Cast<Fruit>();
}

A:

How about using Dictionary to store delegates ?
    Dictionary<string, Func<List<Fruit>>> typeMapper = new Dictionary<string, Func<List<Fruit>>>()
    {
        {"Apple", () => { return getFruit<Apple>(); } },
        {"Orange", () => { return getFruit<Orange>(); } }
    };

    List<Fruit> fruitList = typeMapper["Apple"]();

