You can do this using reflection and generic method concpt.
Ideally you can create a generic method like below
public T InvokeFunction<T>(repositoryPerson function, params object[] parameters)
{
object instance = Activator.CreateInstance(typeof(RepositoryPerson));
MethodInfo mi = instance.GetType().GetMethod(function.ToString());
return (T)mi.Invoke(instance, parameters);
}
An enum with all the possibile function names would be better
enum repositoryPerson
{
GetAllPerson, GetPersonById, RunCustomStoreProcedure
}
Here you can have a facade which represents all the functions for the repository
public class RepositoryPerson
{
public IList<Person> GetAllPerson()
{
//return your result
return null;
}
public Person GetPersonById(int id)
{
//return your result
return null;
}
public int RunCustomStoreProcedure(int param1, string param2)
{
//return your result
return 0;
}
}
Now you can call your function like below
IList<Person> persons = InvokeFunction<IList<Person>>(repositoryPerson.GetAllPerson);
Person person = InvokeFunction<Person>(repositoryPerson.GetPersonById, 5);
int val = InvokeFunction<int>(repositoryPerson.RunCustomStoreProcedure, 2, "3", "parame4");
Please note that this is just a concept. Definitely you have to do type check, null reference etc. while calling your actual functions.