In exploring an answer to my question on how to dynamically specify an entity or its interfaced representation, I discovered that ef6 has a generic repository implementation as such:
var repos1 = _dbContext.Set<Widget1>();
Is there a way to specify Widget1 through either reflection or some other mechanism which does not require that I run through a switch statement to get the right entity?
More specifically, I have a case where I would like to have a function signature similar to the following:
public IEnumerable<T> Search<T>(string SearchTerm, string EntityName) where T : class
{
// EntityName = Widget1
// return an interface as above, but for the EntityName passed to the function
}
The main interest in the function signature is not that it is using T but that I would like to pass EntityName as a string. The other elements are left overs from using a hand rolled generic repository implementation.
Aucun commentaire:
Enregistrer un commentaire