1

I am trying to achieve following, is it possible?

Type T = Type.GetType("EntityName")
IEnumerable<T> entities = BaseRepository.GetEntities(searchCriteria) as IEnumerable<T>();
NullPoiиteя
  • 56,591
  • 22
  • 125
  • 143
asolvent
  • 821
  • 13
  • 26
  • 1
    No, you couldn't do that. You should probably think about creating a good *generic* base repository and think about what methods (simple CRUD) you could universally support and then how to customize the rest. Some use `Expression>` parameters to allow arbitrarily many query possibilities, others create custom derived repositories that know the specific queries to support while allowing little to no additional parameterization. – Anthony Pegram May 14 '13 at 04:50
  • 1
    Answered here: [Generics in C#, using type of a variable as parameter](http://stackoverflow.com/q/2107845/254830). You should think about doing this another way, though, like what @user414076 is pointing out. Jon Skeet talks about that a little in his answer. – doppelgreener May 14 '13 at 04:53

0 Answers0