It looks to me like you mean it the other way around. You don't want to pass interface types to Context.Get<>
, do you?
// is this what you mean?
if (typeof(T) == typeof(ITeacher))
return Context.Get(id);
If it is, you'll need to use MakeGenericMethod
, see this for an example (note the caching part).
If it is not, you might be misunderstanding some concepts of LINQ and/or Repository pattern.
However I'm curious why did you decide to use interfaces. LINQ objects are POCO anyways, why adding another layer of abstraction which involves (grrsh!) calling generic methods on DataContext via reflection?