This seems like basic problem, but I’m struggling with it (maybe because of tiredness).
E.g. – if i create instance of repository like this =>
var repositoryType = typeof(Repository<>).MakeGenericType(entityType);
// repository type==object :(
var repository = ServiceLocator.Current.GetInstance(repositoryType);
What’s the best way to call repository.All() method? Is reflection the only way?
It depends whether
Repository<>exposes some non-generic interface (likeITablecompared toTable<T>in LINQ-to-SQL). If not, you have to use reflection. If it does, then cast to the non-generic interface:In 4.0, you could also consider
dynamic: